Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8743,6 +8743,9 @@ const CONST = {
WALLET: {
ADD_BANK_ACCOUNT: 'Wallet-AddBankAccount',
},
REIMBURSEMENT_ACCOUNT: {
YOUR_DATA_IS_SECURE: 'ReimbursementAccount-YourDataIsSecure',
},
SOCIALS: {
LINK: 'Socials',
},
Expand Down
6 changes: 5 additions & 1 deletion src/components/SubStepForms/CountryFullStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ function CountryFullStep({onBackButtonPress, stepNames, onSubmit, policyID, isCo
const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT, {canBeMissing: true});
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {canBeMissing: true});

const currency = reimbursementAccountDraft?.currency ?? policy?.outputCurrency ?? '';
const currency =
reimbursementAccountDraft?.currency ??
policy?.outputCurrency ??
reimbursementAccount?.achData?.currency ??
CONST.BBA_COUNTRY_CURRENCY_MAP[reimbursementAccount?.achData?.country ?? ''];

const shouldAllowChange = currency === CONST.CURRENCY.EUR;
const defaultCountries = shouldAllowChange ? CONST.ALL_EUROPEAN_UNION_COUNTRIES : CONST.ALL_COUNTRIES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import ScrollView from '@components/ScrollView';
import Section from '@components/Section';
import Text from '@components/Text';
import TextLink from '@components/TextLink';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
Expand All @@ -23,6 +24,7 @@ import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {getLatestError, getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils';
import Navigation from '@libs/Navigation/Navigation';
import {hasActiveAdminWorkspaces} from '@libs/PolicyUtils';
import WorkspaceResetBankAccountModal from '@pages/workspace/WorkspaceResetBankAccountModal';
import {goToWithdrawalAccountSetupStep, openPlaidView, updateReimbursementAccountDraft} from '@userActions/BankAccounts';
import {openExternalLink} from '@userActions/Link';
Expand Down Expand Up @@ -100,6 +102,10 @@ function VerifiedBankAccountFlowEntryPoint({
const [reimbursementAccountOptionPressed] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT_OPTION_PRESSED, {canBeMissing: true});
const isAccountValidated = account?.validated ?? false;

const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true});
const {login: currentUserLogin} = useCurrentUserPersonalDetails();
const isCurrentUserPolicyAdmin = hasActiveAdminWorkspaces(currentUserLogin, allPolicies);

const personalBankAccounts = bankAccountList ? Object.keys(bankAccountList).filter((key) => bankAccountList[key].accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT) : [];

const removeExistingBankAccountDetails = () => {
Expand Down Expand Up @@ -184,6 +190,14 @@ function VerifiedBankAccountFlowEntryPoint({
prepareNextStep(CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID);
};

const navigateAfterReset = () => {
// we want to navigate after reset if the user comes from settings/wallet or settings/wallet/bank-account-purpose
if (!backTo.includes(ROUTES.SETTINGS_WALLET)) {
return;
}
Navigation.goBack(isCurrentUserPolicyAdmin ? ROUTES.SETTINGS_BANK_ACCOUNT_PURPOSE : ROUTES.SETTINGS_WALLET);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that if user is not an admin, resetting the flow will close RHP and open wallet page?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, because non-admin should not have access to the purpose page

};

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand Down Expand Up @@ -279,6 +293,7 @@ function VerifiedBankAccountFlowEntryPoint({
onPress={() => openExternalLink(CONST.ENCRYPTION_AND_SECURITY_HELP_URL)}
style={[styles.flexRow, styles.alignItemsCenter]}
accessibilityLabel={translate('bankAccount.yourDataIsSecure')}
sentryLabel={CONST.SENTRY_LABEL.REIMBURSEMENT_ACCOUNT.YOUR_DATA_IS_SECURE}
>
<TextLink href={CONST.ENCRYPTION_AND_SECURITY_HELP_URL}>{translate('bankAccount.yourDataIsSecure')}</TextLink>
<View style={styles.ml1}>
Expand All @@ -299,6 +314,7 @@ function VerifiedBankAccountFlowEntryPoint({
setNonUSDBankAccountStep={setNonUSDBankAccountStep}
setShouldShowContinueSetupButton={setShouldShowContinueSetupButton}
setIsResettingBankAccount={setIsResettingBankAccount}
navigateAfterReset={navigateAfterReset}
/>
)}
</ScreenWrapper>
Expand Down
7 changes: 7 additions & 0 deletions src/pages/workspace/WorkspaceResetBankAccountModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ type WorkspaceResetBankAccountModalProps = {

/** Method to set the state of isResettingBankAccount */
setIsResettingBankAccount?: (isResetting: boolean) => void;

/** Method to navigate back after resetting bank account from wallet */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** Method to navigate back after resetting bank account from wallet */
/** Method to navigate after resetting bank account */

navigateAfterReset?: () => void;
};

function WorkspaceResetBankAccountModal({
Expand All @@ -42,6 +45,7 @@ function WorkspaceResetBankAccountModal({
isNonUSDWorkspace,
setShouldShowContinueSetupButton,
setIsResettingBankAccount,
navigateAfterReset,
}: WorkspaceResetBankAccountModalProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand Down Expand Up @@ -104,6 +108,9 @@ function WorkspaceResetBankAccountModal({
setUSDBankAccountStep(null);
}
}
if (navigateAfterReset) {
navigateAfterReset();
}
};

return (
Expand Down
Loading