diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index 8632c150be68..920c0eecfdd2 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -442,8 +442,10 @@ function getOnyxDataForConnectingVBBAAndLastPaymentMethod(policyID?: string, las /** * Submit Bank Account step with Plaid data so php can perform some checks. + * + * @returns true when redirected to the manual flow (Chase Plaid dummy numbers). */ -function connectBankAccountWithPlaid(bankAccountID: number, selectedPlaidBankAccount: PlaidBankAccount, policyID: string | undefined) { +function connectBankAccountWithPlaid(bankAccountID: number, selectedPlaidBankAccount: PlaidBankAccount, policyID: string | undefined): boolean { const isChaseBank = selectedPlaidBankAccount.bankName?.toLowerCase() === CONST.BANK_NAMES.CHASE; if (bankAccountID === CONST.DEFAULT_NUMBER_ID && isChaseBank) { Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, { @@ -457,7 +459,7 @@ function connectBankAccountWithPlaid(bankAccountID: number, selectedPlaidBankAcc accountNumber: '', routingNumber: '', }); - return; + return true; } const parameters: ConnectBankAccountParams = { @@ -473,6 +475,7 @@ function connectBankAccountWithPlaid(bankAccountID: number, selectedPlaidBankAcc }; API.write(WRITE_COMMANDS.CONNECT_BANK_ACCOUNT_WITH_PLAID, parameters, getVBBADataForOnyx()); + return false; } /** diff --git a/src/pages/ReimbursementAccount/USD/BankInfo/BankInfo.tsx b/src/pages/ReimbursementAccount/USD/BankInfo/BankInfo.tsx index 0d9aac556000..864d4a123b5e 100644 --- a/src/pages/ReimbursementAccount/USD/BankInfo/BankInfo.tsx +++ b/src/pages/ReimbursementAccount/USD/BankInfo/BankInfo.tsx @@ -80,7 +80,7 @@ function BankInfo({onBackButtonPress, onSubmit, policyID}: BankInfoProps) { if (plaidAccountIDChanged) { deletePaymentBankAccount(bankAccountID, undefined); } - connectBankAccountWithPlaid( + const redirectedToManual = connectBankAccountWithPlaid( plaidAccountIDChanged ? CONST.DEFAULT_NUMBER_ID : bankAccountID, { [BANK_INFO_STEP_KEYS.ROUTING_NUMBER]: data[BANK_INFO_STEP_KEYS.ROUTING_NUMBER] ?? '', @@ -93,6 +93,11 @@ function BankInfo({onBackButtonPress, onSubmit, policyID}: BankInfoProps) { }, policyID, ); + + // No bank account was created. Stay on this step so the manual form can create it before advancing. + if (redirectedToManual) { + return; + } } markSubmitting(); };