Skip to content

Commit

Permalink
Merge pull request #5771 from Expensify/alberto-workspaceSections
Browse files Browse the repository at this point in the history
Do not always clear Onyx VBA data when accessing workspace sections
  • Loading branch information
marcaaron authored Oct 13, 2021
2 parents 23bcfc9 + ab5acf4 commit d61248f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,21 @@ function fetchUserWallet() {
* Fetch the bank account currently being set up by the user for the free plan if it exists.
*
* @param {String} [stepToOpen]
* @param {String} [localBankAccountState]
*/
function fetchFreePlanVerifiedBankAccount(stepToOpen) {
function fetchFreePlanVerifiedBankAccount(stepToOpen, localBankAccountState) {
// Remember which account BankAccountStep subStep the user had before so we can set it later
const subStep = lodashGet(reimbursementAccountInSetup, 'subStep', '');
const initialData = {loading: true, error: ''};

// Some UI needs to know the bank account state during the loading process, so we are keeping it in Onyx if passed
if (localBankAccountState) {
initialData.achData = {state: localBankAccountState};
}

// 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, error: ''});
Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, initialData);
let bankAccountID;

API.Get({
Expand Down
3 changes: 2 additions & 1 deletion src/pages/workspace/WorkspacePageWithSections.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ const defaultProps = {

class WorkspacePageWithSections extends React.Component {
componentDidMount() {
fetchFreePlanVerifiedBankAccount();
const achState = lodashGet(this.props.reimbursementAccount, 'achData.state', '');
fetchFreePlanVerifiedBankAccount('', achState);
}

render() {
Expand Down

0 comments on commit d61248f

Please sign in to comment.