Skip to content

Commit 1803120

Browse files
authored
Merge pull request #4923 from Expensify/amal-bank-account-workspace-id
Link Workspace ID to reimbursement account setup so it is accessible during validation step
2 parents ec9a319 + ac44cbf commit 1803120

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

src/ONYXKEYS.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,7 @@ export default {
119119

120120
// Stores information about the active reimbursement account being set up
121121
REIMBURSEMENT_ACCOUNT: 'reimbursementAccount',
122+
123+
// Stores Workspace ID that will be tied to reimbursement account during setup
124+
REIMBURSEMENT_ACCOUNT_WORKSPACE_ID: 'reimbursementAccountWorkspaceID',
122125
};

src/libs/actions/BankAccounts.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ Onyx.connect({
3030
},
3131
});
3232

33+
let reimbursementAccountWorkspaceID = null;
34+
Onyx.connect({
35+
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT_WORKSPACE_ID,
36+
callback: (val) => {
37+
reimbursementAccountWorkspaceID = val;
38+
},
39+
});
40+
3341
/**
3442
* Gets the Plaid Link token used to initialize the Plaid SDK
3543
*/
@@ -409,7 +417,7 @@ function fetchFreePlanVerifiedBankAccount(stepToOpen) {
409417
let currentStep = reimbursementAccountInSetup.currentStep;
410418
const achData = bankAccount ? bankAccount.toACHData() : {};
411419
achData.useOnfido = true;
412-
achData.policyID = '';
420+
achData.policyID = reimbursementAccountWorkspaceID || '';
413421
achData.isInSetup = !bankAccount || bankAccount.isInSetup();
414422
achData.bankAccountInReview = bankAccount && bankAccount.isVerifying();
415423
achData.domainLimit = 0;
@@ -803,6 +811,10 @@ function hideBankAccountErrors() {
803811
Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {error: '', existingOwnersList: ''});
804812
}
805813

814+
function setWorkspaceIDForReimbursementAccount(workspaceID) {
815+
Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT_WORKSPACE_ID, workspaceID);
816+
}
817+
806818
export {
807819
activateWallet,
808820
addPersonalBankAccount,
@@ -817,4 +829,5 @@ export {
817829
validateBankAccount,
818830
hideBankAccountErrors,
819831
showBankAccountFormValidationError,
832+
setWorkspaceIDForReimbursementAccount,
820833
};

src/pages/workspace/WorkspaceCardPage.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import HeroCardWebImage from '../../../assets/images/cascading-cards-web.svg';
2424
import HeroCardMobileImage from '../../../assets/images/cascading-cards-mobile.svg';
2525
import BankAccount from '../../libs/models/BankAccount';
2626
import {openSignedInLink} from '../../libs/actions/App';
27+
import {setWorkspaceIDForReimbursementAccount} from '../../libs/actions/BankAccounts';
2728

2829
const propTypes = {
2930
/* Onyx Props */
@@ -40,6 +41,15 @@ const propTypes = {
4041
isUsingExpensifyCard: PropTypes.bool,
4142
}),
4243

44+
/** URL Route params */
45+
route: PropTypes.shape({
46+
/** Params from the URL path */
47+
params: PropTypes.shape({
48+
/** policyID passed via route: /workspace/:policyID/people */
49+
policyID: PropTypes.string,
50+
}),
51+
}).isRequired,
52+
4353
/** Bank account currently in setup */
4454
reimbursementAccount: PropTypes.shape({
4555
/** Additional data */
@@ -70,6 +80,7 @@ const WorkspaceCardPage = ({
7080
betas,
7181
user,
7282
translate,
83+
route,
7384
isSmallScreenWidth,
7485
isMediumScreenWidth,
7586
reimbursementAccount,
@@ -95,6 +106,7 @@ const WorkspaceCardPage = ({
95106
} else if (user.isUsingExpensifyCard) {
96107
openSignedInLink(CONST.MANAGE_CARDS_URL);
97108
} else {
109+
setWorkspaceIDForReimbursementAccount(route.params.policyID);
98110
Navigation.navigate(ROUTES.getBankAccountRoute());
99111
}
100112
};

0 commit comments

Comments
 (0)