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

Autofill previously entered accounting and routing numbers #4477

Merged
merged 5 commits into from
Aug 10, 2021
Merged
Changes from 1 commit
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
18 changes: 17 additions & 1 deletion src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ function fetchUserWallet() {
* @param {String} [stepToOpen]
*/
function fetchFreePlanVerifiedBankAccount(stepToOpen) {
const oldACHData = {
accountNumber: reimbursementAccountInSetup.accountNumber || '',
routingNumber: reimbursementAccountInSetup.routingNumber || '',
};

// 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});
Expand Down Expand Up @@ -478,7 +483,18 @@ function fetchFreePlanVerifiedBankAccount(stepToOpen) {
goToWithdrawalAccountSetupStep(currentStep, achData);
})
.finally(() => {
Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {loading: false});
const dataToMerge = {
loading: false,
};

// If we didn't get a routingNumber and accountNumber from the response and we have previously saved
// values, autofill them
if (!reimbursementAccountInSetup.routingNumber && !reimbursementAccountInSetup.accountNumber
&& oldACHData.routingNumber && oldACHData.accountNumber) {
dataToMerge.achData = oldACHData;
}

Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, dataToMerge);
});
});
}
Expand Down