From 1c0c4ea22f3a8fe0aedd7f1dd69390f44329eb5c Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Fri, 6 Aug 2021 17:10:47 -0600 Subject: [PATCH 1/5] prevent ui change --- src/libs/actions/BankAccounts.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index b3f016ac3ab4..a020aea2bb80 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -330,7 +330,8 @@ function fetchUserWallet() { function fetchFreePlanVerifiedBankAccount(stepToOpen) { // 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}); + // We temporarily keep the achData state to prevent UI changes while fetching. + Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {loading: true, achData: {state: reimbursementAccountInSetup.state}}); let bankAccountID; API.Get({ From f995b9b248fff7f9aedb9e46f1dced1534309f92 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Fri, 6 Aug 2021 17:15:21 -0600 Subject: [PATCH 2/5] use lodashget --- src/libs/actions/BankAccounts.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index a020aea2bb80..2876cf790eba 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -331,7 +331,10 @@ function fetchFreePlanVerifiedBankAccount(stepToOpen) { // 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. // We temporarily keep the achData state to prevent UI changes while fetching. - Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {loading: true, achData: {state: reimbursementAccountInSetup.state}}); + Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, { + loading: true, + achData: {state: lodashGet(reimbursementAccountInSetup, 'state', '')}, + }); let bankAccountID; API.Get({ From 22c872cfb2409cc0e1e2b774102f2da4a0db09f6 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 9 Aug 2021 10:24:59 -0600 Subject: [PATCH 3/5] achData default state --- src/libs/actions/BankAccounts.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 2876cf790eba..cc01b979f4f4 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -406,6 +406,7 @@ function fetchFreePlanVerifiedBankAccount(stepToOpen) { achData.isInSetup = !bankAccount || bankAccount.isInSetup(); achData.bankAccountInReview = bankAccount && bankAccount.isVerifying(); achData.domainLimit = 0; + achData.state = lodashGet(achData, 'state', ''); // If the bank account has already been created in the db and is not yet open // let's show the manual form with the previously added values From 62049474b1a681a5a68b89df6e5a7928b36c7981 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 9 Aug 2021 11:20:02 -0600 Subject: [PATCH 4/5] move comment --- src/libs/actions/BankAccounts.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index cc01b979f4f4..789b171f83c7 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -330,9 +330,10 @@ function fetchUserWallet() { function fetchFreePlanVerifiedBankAccount(stepToOpen) { // 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. - // We temporarily keep the achData state to prevent UI changes while fetching. Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, { loading: true, + + // We temporarily keep the achData state to prevent UI changes while fetching. achData: {state: lodashGet(reimbursementAccountInSetup, 'state', '')}, }); let bankAccountID; From e24e3fb956ac67f6c6003c57c7a0c22f979a64a6 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 9 Aug 2021 12:58:54 -0600 Subject: [PATCH 5/5] add edge case comment --- src/libs/actions/BankAccounts.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 789b171f83c7..e9ed3ac640a7 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -407,6 +407,10 @@ function fetchFreePlanVerifiedBankAccount(stepToOpen) { achData.isInSetup = !bankAccount || bankAccount.isInSetup(); achData.bankAccountInReview = bankAccount && bankAccount.isVerifying(); achData.domainLimit = 0; + + // Adding a default empty state to make sure we override the temporary one we are keeping + // for UI purposes. This covers an edge case in which a user deleted their bank account, + // but would still see Finish Setup in the UI, instead of Get Started. achData.state = lodashGet(achData, 'state', ''); // If the bank account has already been created in the db and is not yet open