Skip to content

Commit

Permalink
Merge pull request #4923 from Expensify/amal-bank-account-workspace-id
Browse files Browse the repository at this point in the history
Link Workspace ID to reimbursement account setup so it is accessible during validation step
  • Loading branch information
robertjchen authored Aug 30, 2021
2 parents ec9a319 + ac44cbf commit 1803120
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/ONYXKEYS.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,7 @@ export default {

// Stores information about the active reimbursement account being set up
REIMBURSEMENT_ACCOUNT: 'reimbursementAccount',

// Stores Workspace ID that will be tied to reimbursement account during setup
REIMBURSEMENT_ACCOUNT_WORKSPACE_ID: 'reimbursementAccountWorkspaceID',
};
15 changes: 14 additions & 1 deletion src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ Onyx.connect({
},
});

let reimbursementAccountWorkspaceID = null;
Onyx.connect({
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT_WORKSPACE_ID,
callback: (val) => {
reimbursementAccountWorkspaceID = val;
},
});

/**
* Gets the Plaid Link token used to initialize the Plaid SDK
*/
Expand Down Expand Up @@ -409,7 +417,7 @@ function fetchFreePlanVerifiedBankAccount(stepToOpen) {
let currentStep = reimbursementAccountInSetup.currentStep;
const achData = bankAccount ? bankAccount.toACHData() : {};
achData.useOnfido = true;
achData.policyID = '';
achData.policyID = reimbursementAccountWorkspaceID || '';
achData.isInSetup = !bankAccount || bankAccount.isInSetup();
achData.bankAccountInReview = bankAccount && bankAccount.isVerifying();
achData.domainLimit = 0;
Expand Down Expand Up @@ -803,6 +811,10 @@ function hideBankAccountErrors() {
Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {error: '', existingOwnersList: ''});
}

function setWorkspaceIDForReimbursementAccount(workspaceID) {
Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT_WORKSPACE_ID, workspaceID);
}

export {
activateWallet,
addPersonalBankAccount,
Expand All @@ -817,4 +829,5 @@ export {
validateBankAccount,
hideBankAccountErrors,
showBankAccountFormValidationError,
setWorkspaceIDForReimbursementAccount,
};
12 changes: 12 additions & 0 deletions src/pages/workspace/WorkspaceCardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import HeroCardWebImage from '../../../assets/images/cascading-cards-web.svg';
import HeroCardMobileImage from '../../../assets/images/cascading-cards-mobile.svg';
import BankAccount from '../../libs/models/BankAccount';
import {openSignedInLink} from '../../libs/actions/App';
import {setWorkspaceIDForReimbursementAccount} from '../../libs/actions/BankAccounts';

const propTypes = {
/* Onyx Props */
Expand All @@ -40,6 +41,15 @@ const propTypes = {
isUsingExpensifyCard: PropTypes.bool,
}),

/** URL Route params */
route: PropTypes.shape({
/** Params from the URL path */
params: PropTypes.shape({
/** policyID passed via route: /workspace/:policyID/people */
policyID: PropTypes.string,
}),
}).isRequired,

/** Bank account currently in setup */
reimbursementAccount: PropTypes.shape({
/** Additional data */
Expand Down Expand Up @@ -70,6 +80,7 @@ const WorkspaceCardPage = ({
betas,
user,
translate,
route,
isSmallScreenWidth,
isMediumScreenWidth,
reimbursementAccount,
Expand All @@ -95,6 +106,7 @@ const WorkspaceCardPage = ({
} else if (user.isUsingExpensifyCard) {
openSignedInLink(CONST.MANAGE_CARDS_URL);
} else {
setWorkspaceIDForReimbursementAccount(route.params.policyID);
Navigation.navigate(ROUTES.getBankAccountRoute());
}
};
Expand Down

0 comments on commit 1803120

Please sign in to comment.