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

fix blinking loader in connect bank account page #29260

Merged
merged 4 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ function validateBankAccount(bankAccountID, validateCode) {
);
}

function clearReimbursementAccount() {
Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, null);
}

function openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep) {
const onyxData = {
optimisticData: [
Expand Down Expand Up @@ -436,6 +440,7 @@ export {
deletePaymentBankAccount,
handlePlaidError,
openPersonalBankAccountSetupView,
clearReimbursementAccount,
openReimbursementAccountPage,
updateBeneficialOwnersForBankAccount,
updateCompanyInformationForBankAccount,
Expand Down
12 changes: 9 additions & 3 deletions src/pages/ReimbursementAccount/ReimbursementAccountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ class ReimbursementAccountPage extends React.Component {
this.goBack = this.goBack.bind(this);
this.requestorStepRef = React.createRef();

// The first time we open this page, the props.reimbursementAccount has not been loaded from the server.
// Calculating shouldShowContinueSetupButton on the default data doesn't make sense, and we should recalculate
// The first time we open this page, props.reimbursementAccount is either not available in Onyx
// or only partial data loaded where props.reimbursementAccount.achData.currentStep is not available
// Calculating shouldShowContinueSetupButton on first page open doesn't make sense, and we should recalculate
// it once we get the response from the server the first time in componentDidUpdate.
const hasACHDataBeenLoaded = this.props.reimbursementAccount !== ReimbursementAccountProps.reimbursementAccountDefaultProps;
const hasACHDataBeenLoaded =
this.props.reimbursementAccount !== ReimbursementAccountProps.reimbursementAccountDefaultProps && _.has(this.props.reimbursementAccount, 'achData.currentStep');
this.state = {
hasACHDataBeenLoaded,
shouldShowContinueSetupButton: hasACHDataBeenLoaded ? this.getShouldShowContinueSetupButtonInitialValue() : false,
Expand Down Expand Up @@ -183,6 +185,10 @@ class ReimbursementAccountPage extends React.Component {
Navigation.navigate(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute(this.getRouteForCurrentStep(currentStep), policyId, backTo));
}

componentWillUnmount() {
BankAccounts.clearReimbursementAccount();
}

getFieldsForStep(step) {
switch (step) {
case CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT:
Expand Down