diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index e81e2b863190..ab7f93858555 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -242,6 +242,47 @@ function validateBankAccount(bankAccountID, validateCode) { }); } +function openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep) { + const onyxData = { + optimisticData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + errors: null, + isLoading: true, + }, + }, + ], + successData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isLoading: false, + }, + }, + ], + failureData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isLoading: false, + }, + }, + ], + }; + + const param = { + stepToOpen, + subStep, + localCurrentStep, + }; + + return API.read('OpenReimbursementAccountPage', param, onyxData); +} + /** * Updates the bank account in the database with the company step data * @@ -323,12 +364,13 @@ function verifyIdentityForBankAccount(bankAccountID, onfidoData) { export { addPersonalBankAccount, - connectBankAccountManually, + clearOnfidoToken, clearPersonalBankAccount, clearPlaid, - clearOnfidoToken, + connectBankAccountManually, connectBankAccountWithPlaid, deletePaymentBankAccount, + openReimbursementAccountPage, updateBeneficialOwnersForBankAccount, updateCompanyInformationForBankAccount, updatePersonalInformationForBankAccount, diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index 4b532a8daf6c..4cf151b2a2f1 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -18,6 +18,7 @@ import getPlaidOAuthReceivedRedirectURI from '../../libs/getPlaidOAuthReceivedRe import Text from '../../components/Text'; import {withNetwork} from '../../components/OnyxProvider'; import networkPropTypes from '../../components/networkPropTypes'; +import * as store from '../../libs/actions/ReimbursementAccount/store'; // Steps import BankAccountStep from './BankAccountStep'; @@ -150,9 +151,10 @@ class ReimbursementAccountPage extends React.Component { // We can specify a step to navigate to by using route params when the component mounts. // We want to use the same stepToOpen variable when the network state changes because we can be redirected to a different step when the account refreshes. const stepToOpen = this.getStepToOpenFromRouteParams(); - - // If we are trying to navigate to `/bank-account/new` and we already have a bank account then don't allow returning to `/new` - BankAccounts.fetchFreePlanVerifiedBankAccount(stepToOpen !== CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT ? stepToOpen : ''); + const reimbursementAccount = store.getReimbursementAccountInSetup(); + const subStep = reimbursementAccount.subStep || ''; + const localCurrentStep = reimbursementAccount.currentStep || ''; + BankAccounts.openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep); } render() {