-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add a loading functionality to eliminate race condition in ResetFreeBankAccount #12112
Conversation
Looking at your videos, I see a weird panel behavior where is starts to close and opens back |
@@ -58,6 +59,14 @@ class WorkspaceBankAccountPage extends React.Component { | |||
this.navigateToBankAccountRoute(); | |||
} | |||
|
|||
componentDidUpdate(prevProps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm ....
So, you're doing this because you want to wait for the RestartBankAccountSetup call to finish (which deletes the free plan bank account) before calling navigateToBankAccountRoute (which calls fetchFreePlanVerifiedBankAccount), so it doesn't end up fetching a deleted bank account.
Personally, I would prefer calling API.makeRequestWithSideEffects('RestartBankAccountSetup'
than doing this even though I know we want to avoid it.
Or another alternative would be to somehow pass a param to navigateToBankAccountRoute to tell it not to call fetchFreePlanVerifiedBankAccount in this case, as we should just be able to rely on the optimistic data that we put (that resets REIMBURSEMENT_ACCOUNT). Can you try it see if it would work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that second option better of passing a route parameter to avoid the fetch. Another alternative to that would be to have two components:
- Does the fetch on mounting (this is the one users normally hit in the flow)
- Doesn't do the fetch (you can only get to this component by being redirected to it from
resetFreePlanBankAccount()
It's sorta the same thing as a route parameter but implemented in a slightly different way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats interesting. I wonder if we can do a bit of both. There are actually two problems here:
- User resets VBBA and then we immediately do a fetch
- When user logs in for the first time, we don't do any sort of fetch before
WorkspaceBankAccountPage
, so we skip this step entirely. Which is a bit strange
We could:
- Always fetch VBBA upon getting to
WorkspaceBankAccountPage
component - If we navigate to
/bank-account
from this component, we always skip fetching (since we just did one) - If user chooses to "Start Over", we call the API. Skip the fetch, so we have no issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing in a param to navigate is trickier than I thought. Still working
Closing in favor of this solution: #12422 |
@ctkochan22 this PR should be closed, right? |
Yes! |
@Expensify/pullerbear @MariaHCD @nkuoch
Details
When adding a VBBA, and you click "Start Over". There is a race between:
ReimbursementAccountPage.js
Sometimes ResetFreeBankAccount will not finish before we open the ReimbursementAccountPage, which means we still show the last step of the previous flow, despite the setup VBBA was reset
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/238317
Tests / QA
user_good
andpass_good
. Get past the CompanyStep, whatever you need to do to get to Personal Information (RequestorStep)PR Review Checklist
PR Author Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
filesWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)PR Reviewer Checklist
The reviewer will copy/paste it into a new comment and complete it after the author checklist is completed
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
).src/languages/*
filesWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
have been tested & I retested again)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Screenshots
Web
Web
Mobile Web - Chrome
Mobile Chrome
Mobile Web - Safari
Mobile Safari
Desktop
Desktop
iOS
iOS
Android