diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index b3f016ac3ab4..e9ed3ac640a7 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -330,7 +330,12 @@ function fetchUserWallet() { function fetchFreePlanVerifiedBankAccount(stepToOpen) { // We are using set here since we will rely on data from the server (not local data) to populate the VBA flow // and determine which step to navigate to. - Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {loading: true}); + Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, { + loading: true, + + // We temporarily keep the achData state to prevent UI changes while fetching. + achData: {state: lodashGet(reimbursementAccountInSetup, 'state', '')}, + }); let bankAccountID; API.Get({ @@ -403,6 +408,11 @@ function fetchFreePlanVerifiedBankAccount(stepToOpen) { achData.bankAccountInReview = bankAccount && bankAccount.isVerifying(); achData.domainLimit = 0; + // Adding a default empty state to make sure we override the temporary one we are keeping + // for UI purposes. This covers an edge case in which a user deleted their bank account, + // but would still see Finish Setup in the UI, instead of Get Started. + achData.state = lodashGet(achData, 'state', ''); + // If the bank account has already been created in the db and is not yet open // let's show the manual form with the previously added values achData.subStep = bankAccount && bankAccount.isInSetup()