Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not always clear Onyx VBA data when accessing workspace sections #5771

Merged
merged 5 commits into from
Oct 13, 2021
Merged
Changes from 3 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
4 changes: 1 addition & 3 deletions src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,7 @@ function fetchFreePlanVerifiedBankAccount(stepToOpen) {
// Remember which account BankAccountStep subStep the user had before so we can set it later
const subStep = lodashGet(reimbursementAccountInSetup, 'subStep', '');

// 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.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {loading: true, error: ''});
Copy link
Contributor

Choose a reason for hiding this comment

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

Kinda want to propose a less risky change here. Here's how it goes...

Since the /bank-account flow may be expecting multiple fields to be "reset" before we fetch the bank account then we should try to only carry over the state that we need for now.

I think to solve the current issue we could do something like:

const initialData = {loading: true, error: ''};
const state = lodashGet(reimbursementAccountInSetup, 'achData.state');

if (state === BankAccount.STATE.OPEN) {
    initialData.achData = {state: BankAccount.STATE.OPEN};
}

Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, initialData);

Copy link
Contributor Author

@Gonals Gonals Oct 13, 2021

Choose a reason for hiding this comment

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

I think this is a pretty good solution, as it shouldn't affect the add bank account flow, which was my main worry with the current one. However, it won't work as-is. At this point, reimbursementAccountInSetup is still empty, so there's no state there.
We can either pass a flag from WorspacePageWithSections, as I was doing before, or do an Onyx.connect. I think the first option might be better, but I can go for either. Any preference @marcaaron?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've pushed changes for solution #1 (with the flag). LMK what you think

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah bummer sounds like a good case for Onyx.isInitialized() if it existed 😄

let bankAccountID;

API.Get({
Expand Down