Skip to content

Commit f80de72

Browse files
authored
Merge pull request #29260 from honnamkuan/27901
fix blinking loader in connect bank account page
2 parents 9e19e40 + 3eaa3bc commit f80de72

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/libs/actions/BankAccounts.js

+5
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ function validateBankAccount(bankAccountID, validateCode) {
275275
);
276276
}
277277

278+
function clearReimbursementAccount() {
279+
Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, null);
280+
}
281+
278282
function openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep) {
279283
const onyxData = {
280284
optimisticData: [
@@ -436,6 +440,7 @@ export {
436440
deletePaymentBankAccount,
437441
handlePlaidError,
438442
openPersonalBankAccountSetupView,
443+
clearReimbursementAccount,
439444
openReimbursementAccountPage,
440445
updateBeneficialOwnersForBankAccount,
441446
updateCompanyInformationForBankAccount,

src/pages/ReimbursementAccount/ReimbursementAccountPage.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ class ReimbursementAccountPage extends React.Component {
105105
this.goBack = this.goBack.bind(this);
106106
this.requestorStepRef = React.createRef();
107107

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

188+
componentWillUnmount() {
189+
BankAccounts.clearReimbursementAccount();
190+
}
191+
186192
getFieldsForStep(step) {
187193
switch (step) {
188194
case CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT:

0 commit comments

Comments
 (0)