Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
32 changes: 15 additions & 17 deletions src/pages/AddPersonalBankAccountPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback, useContext, useEffect} from 'react';
import React, {useContext, useEffect} from 'react';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import ConfirmationPage from '@components/ConfirmationPage';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
Expand All @@ -25,7 +25,7 @@ function AddPersonalBankAccountPage() {
const topmostFullScreenRoute = navigationRef.current?.getRootState()?.routes.findLast((route) => isFullScreenName(route.name));
const kycWallRef = useContext(KYCWallContext);

const goBack = useCallback(() => {
const goBack = () => {
switch (topmostFullScreenRoute?.name) {
case NAVIGATORS.SETTINGS_SPLIT_NAVIGATOR:
Navigation.goBack(ROUTES.SETTINGS_WALLET);
Expand All @@ -37,23 +37,21 @@ function AddPersonalBankAccountPage() {
Navigation.goBack();
break;
}
}, [topmostFullScreenRoute?.name]);
};

const exitFlow = useCallback(
(shouldContinue = false) => {
const exitReportID = personalBankAccount?.exitReportID;
const onSuccessFallbackRoute = personalBankAccount?.onSuccessFallbackRoute ?? '';
const exitFlow = (shouldContinue = false) => {
const exitReportID = personalBankAccount?.exitReportID;
const onSuccessFallbackRoute = personalBankAccount?.onSuccessFallbackRoute ?? '';

if (exitReportID) {
Navigation.dismissModalWithReport({reportID: exitReportID});
} else if (shouldContinue && onSuccessFallbackRoute) {
continueSetup(kycWallRef, onSuccessFallbackRoute);
} else {
goBack();
}
},
[personalBankAccount?.exitReportID, personalBankAccount?.onSuccessFallbackRoute, goBack, kycWallRef],
);
if (exitReportID) {
Navigation.dismissModalWithReport({reportID: exitReportID});
} else if (shouldContinue && onSuccessFallbackRoute) {
continueSetup(kycWallRef, onSuccessFallbackRoute);
} else {
goBack();
clearPersonalBankAccount();
}
};

useEffect(() => clearPersonalBankAccount, []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import type {SubStepProps} from '@hooks/useSubStep/types';
import {getLatestErrorMessage} from '@libs/ErrorUtils';
import {formatE164PhoneNumber} from '@libs/LoginUtils';
import {getCurrentAddress} from '@libs/PersonalDetailsUtils';
import {parsePhoneNumber} from '@libs/PhoneNumber';
import {clearPersonalBankAccountErrors} from '@userActions/BankAccounts';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand All @@ -22,6 +22,7 @@ function ConfirmationStep({onNext, onMove, isEditing}: SubStepProps) {
const [bankAccountPersonalDetails] = useOnyx(ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT_FORM_DRAFT, {canBeMissing: true});
const [personalBankAccount] = useOnyx(ONYXKEYS.PERSONAL_BANK_ACCOUNT, {canBeMissing: true});
const [plaidData] = useOnyx(ONYXKEYS.PLAID_DATA, {canBeMissing: true});
const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false});

const isManual = bankAccountPersonalDetails?.setupType === CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL;

Expand All @@ -32,7 +33,7 @@ function ConfirmationStep({onNext, onMove, isEditing}: SubStepProps) {
const currentAddress = getCurrentAddress(privatePersonalDetails);
const phone = bankAccountPersonalDetails?.phoneNumber ?? privatePersonalDetails?.phoneNumber;
return {
phoneNumber: (phone && parsePhoneNumber(phone, {regionCode: CONST.COUNTRY.US}).number?.significant) ?? '',
phoneNumber: (phone && formatE164PhoneNumber(phone, countryCode)) ?? '',
legalFirstName: bankAccountPersonalDetails?.legalFirstName ?? privatePersonalDetails?.legalFirstName ?? '',
legalLastName: bankAccountPersonalDetails?.legalLastName ?? privatePersonalDetails?.legalLastName ?? '',
addressStreet: bankAccountPersonalDetails?.addressStreet ?? currentAddress?.street ?? '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ function ManualBankAccountDetailsStep({onNext, isEditing}: ManualProps) {
const styles = useThemeStyles();
const {inputCallbackRef} = useAutoFocusInput();

const getDefaultValues = () => ({
routingNumber: bankAccountPersonalDetails?.routingNumber,
accountNumber: bankAccountPersonalDetails?.accountNumber,
});

const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT_FORM> => {
const errors = getFieldRequiredErrors(values, STEP_FIELDS);
const routingNumber = values.routingNumber?.trim();
Expand All @@ -59,8 +54,6 @@ function ManualBankAccountDetailsStep({onNext, isEditing}: ManualProps) {
shouldSaveDraft: true,
});

const defaultValues = getDefaultValues();

return (
<FormProvider
formID={ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT_FORM}
Expand All @@ -79,7 +72,7 @@ function ManualBankAccountDetailsStep({onNext, isEditing}: ManualProps) {
label={translate('bankAccount.routingNumber')}
aria-label={translate('bankAccount.routingNumber')}
role={CONST.ROLE.PRESENTATION}
defaultValue={defaultValues[BANK_INFO_STEP_KEYS.ROUTING_NUMBER]}
value={bankAccountPersonalDetails?.routingNumber ?? ''}
inputMode={CONST.INPUT_MODE.NUMERIC}
shouldSaveDraft
/>
Expand All @@ -90,7 +83,7 @@ function ManualBankAccountDetailsStep({onNext, isEditing}: ManualProps) {
label={translate('bankAccount.accountNumber')}
aria-label={translate('bankAccount.accountNumber')}
role={CONST.ROLE.PRESENTATION}
defaultValue={defaultValues[BANK_INFO_STEP_KEYS.ACCOUNT_NUMBER]}
value={bankAccountPersonalDetails?.accountNumber ?? ''}
inputMode={CONST.INPUT_MODE.NUMERIC}
shouldSaveDraft
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, {useEffect} from 'react';
import {View} from 'react-native';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import Icon from '@components/Icon';
Expand All @@ -17,7 +17,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@navigation/Navigation';
import {updateAddPersonalBankAccountDraft} from '@userActions/BankAccounts';
import {clearPersonalBankAccount, updateAddPersonalBankAccountDraft} from '@userActions/BankAccounts';
import {openExternalLink} from '@userActions/Link';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand All @@ -40,6 +40,10 @@ function AccountFlowEntryPoint({policyName = '', onBackButtonPress}: AccountFlow

const [isPlaidDisabled] = useOnyx(ONYXKEYS.IS_PLAID_DISABLED, {canBeMissing: true});

useEffect(() => {
clearPersonalBankAccount();
}, []);
Comment on lines +43 to +45

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When the Pay-another-user KYC flow sets onSuccessFallbackRoute (via setPersonalBankAccountContinueKYCOnSuccess(ROUTES.ENABLE_PAYMENTS)) and then routes the user through AccountFlowEntryPoint, that screen's mount effect calls clearPersonalBankAccount() → Onyx.set(ONYXKEYS.PERSONAL_BANK_ACCOUNT, null), wiping the entire key including onSuccessFallbackRoute. So when exitFlow(true) later runs on the success page, the shouldContinue && onSuccessFallbackRoute branch fails and the user is bounced back to the "Add bank account" page instead of continuing into the KYC / Onfido flow.

It was fixed here: #92154


const handleConnectManually = () => {
updateAddPersonalBankAccountDraft({
setupType: CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL,
Expand Down
Loading