From f6cd26d0edc0810005238f95276d5e868b1d7370 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 17 Jul 2023 15:22:53 -0600 Subject: [PATCH 1/5] pass policyID to pages --- src/pages/ReimbursementAccount/BankAccountPlaidStep.js | 4 ++++ src/pages/ReimbursementAccount/BankAccountStep.js | 6 ++++++ src/pages/ReimbursementAccount/CompanyStep.js | 4 ++++ src/pages/ReimbursementAccount/ReimbursementAccountPage.js | 3 +++ 4 files changed, 17 insertions(+) diff --git a/src/pages/ReimbursementAccount/BankAccountPlaidStep.js b/src/pages/ReimbursementAccount/BankAccountPlaidStep.js index d74bea73eda0..f78820a09c1b 100644 --- a/src/pages/ReimbursementAccount/BankAccountPlaidStep.js +++ b/src/pages/ReimbursementAccount/BankAccountPlaidStep.js @@ -30,12 +30,16 @@ const propTypes = { /** During the OAuth flow we need to use the plaidLink token that we initially connected with */ plaidLinkOAuthToken: PropTypes.string, + + /* The workspace policyID */ + policyID: PropTypes.string, }; const defaultProps = { plaidData: PlaidDataProps.plaidDataDefaultProps, receivedRedirectURI: null, plaidLinkOAuthToken: '', + policyID: '', }; function BankAccountPlaidStep(props) { diff --git a/src/pages/ReimbursementAccount/BankAccountStep.js b/src/pages/ReimbursementAccount/BankAccountStep.js index 9617fbf46419..676b71350913 100644 --- a/src/pages/ReimbursementAccount/BankAccountStep.js +++ b/src/pages/ReimbursementAccount/BankAccountStep.js @@ -48,6 +48,9 @@ const propTypes = { /* The workspace name */ policyName: PropTypes.string, + + /* The workspace policyID */ + policyID: PropTypes.string, }; const defaultProps = { @@ -56,6 +59,7 @@ const defaultProps = { user: {}, isPlaidDisabled: false, policyName: '', + policyID: '', }; function BankAccountStep(props) { @@ -74,6 +78,7 @@ function BankAccountStep(props) { reimbursementAccountDraft={props.reimbursementAccountDraft} onBackButtonPress={props.onBackButtonPress} getDefaultStateForField={props.getDefaultStateForField} + policyID={props.policyID} /> ); } @@ -85,6 +90,7 @@ function BankAccountStep(props) { reimbursementAccountDraft={props.reimbursementAccountDraft} onBackButtonPress={props.onBackButtonPress} getDefaultStateForField={props.getDefaultStateForField} + policyID={props.policyID} /> ); } diff --git a/src/pages/ReimbursementAccount/CompanyStep.js b/src/pages/ReimbursementAccount/CompanyStep.js index a0982a725d63..4ce3c44fb707 100644 --- a/src/pages/ReimbursementAccount/CompanyStep.js +++ b/src/pages/ReimbursementAccount/CompanyStep.js @@ -40,6 +40,9 @@ const propTypes = { /** Whether or not the user is on a public domain email account or not */ isFromPublicDomain: PropTypes.bool, }), + + /* The workspace policyID */ + policyID: PropTypes.string, }; const defaultProps = { @@ -47,6 +50,7 @@ const defaultProps = { email: null, }, user: {}, + policyID: '', }; class CompanyStep extends React.Component { diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index 007457b21ee2..c6a7274a1a4a 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -330,6 +330,7 @@ class ReimbursementAccountPage extends React.Component { const achData = lodashGet(this.props.reimbursementAccount, 'achData', {}); const currentStep = achData.currentStep || CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT; const policyName = lodashGet(this.props.policy, 'name'); + const policyID = lodashGet(this.props.route, 'policyID'); if (_.isEmpty(this.props.policy) || !Policy.isPolicyOwner(this.props.policy)) { return ( @@ -412,6 +413,7 @@ class ReimbursementAccountPage extends React.Component { plaidLinkOAuthToken={this.props.plaidLinkToken} getDefaultStateForField={this.getDefaultStateForField} policyName={policyName} + policyID={policyID} /> ); } @@ -423,6 +425,7 @@ class ReimbursementAccountPage extends React.Component { reimbursementAccountDraft={this.props.reimbursementAccountDraft} onBackButtonPress={this.goBack} getDefaultStateForField={this.getDefaultStateForField} + policyID={policyID} /> ); } From 20bc70288f5fc494d8f708bc5583d03dedf13b2e Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 17 Jul 2023 15:43:31 -0600 Subject: [PATCH 2/5] pass policyID param to API calls --- src/libs/actions/BankAccounts.js | 13 +++++++++---- .../ReimbursementAccount/BankAccountManualStep.js | 3 ++- .../ReimbursementAccount/BankAccountPlaidStep.js | 4 ++-- src/pages/ReimbursementAccount/CompanyStep.js | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 8ee14e693ba7..8a76873207b2 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -91,8 +91,9 @@ function getVBBADataForOnyx() { * * @param {Number} bankAccountID * @param {Object} selectedPlaidBankAccount + * @param {String} policyID */ -function connectBankAccountWithPlaid(bankAccountID, selectedPlaidBankAccount) { +function connectBankAccountWithPlaid(bankAccountID, selectedPlaidBankAccount, policyID) { const commandName = 'ConnectBankAccountWithPlaid'; const parameters = { @@ -102,6 +103,7 @@ function connectBankAccountWithPlaid(bankAccountID, selectedPlaidBankAccount) { bank: selectedPlaidBankAccount.bankName, plaidAccountID: selectedPlaidBankAccount.plaidAccountID, plaidAccessToken: selectedPlaidBankAccount.plaidAccessToken, + policyID, }; API.write(commandName, parameters, getVBBADataForOnyx()); @@ -327,9 +329,10 @@ function openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep) { * @param {String} [bankAccount.incorporationState] * @param {String} [bankAccount.incorporationDate] * @param {Boolean} [bankAccount.hasNoConnectionToCannabis] + * @param {String} policyID */ -function updateCompanyInformationForBankAccount(bankAccount) { - API.write('UpdateCompanyInformationForBankAccount', bankAccount, getVBBADataForOnyx()); +function updateCompanyInformationForBankAccount(bankAccount, policyID) { + API.write('UpdateCompanyInformationForBankAccount', {bankAccount, policyID}, getVBBADataForOnyx()); } /** @@ -355,9 +358,10 @@ function updateBeneficialOwnersForBankAccount(params) { * @param {String} [accountNumber] * @param {String} [routingNumber] * @param {String} [plaidMask] + * @param {String} policyID * */ -function connectBankAccountManually(bankAccountID, accountNumber, routingNumber, plaidMask) { +function connectBankAccountManually(bankAccountID, accountNumber, routingNumber, plaidMask, policyID) { API.write( 'ConnectBankAccountManually', { @@ -365,6 +369,7 @@ function connectBankAccountManually(bankAccountID, accountNumber, routingNumber, accountNumber, routingNumber, plaidMask, + policyID, }, getVBBADataForOnyx(), ); diff --git a/src/pages/ReimbursementAccount/BankAccountManualStep.js b/src/pages/ReimbursementAccount/BankAccountManualStep.js index fc692f388f5d..3894bbc3b562 100644 --- a/src/pages/ReimbursementAccount/BankAccountManualStep.js +++ b/src/pages/ReimbursementAccount/BankAccountManualStep.js @@ -63,9 +63,10 @@ function BankAccountManualStep(props) { values.accountNumber, values.routingNumber, lodashGet(reimbursementAccountDraft, ['plaidMask']), + props.policyID, ); }, - [reimbursementAccount, reimbursementAccountDraft], + [reimbursementAccount, reimbursementAccountDraft, props.policyID], ); const shouldDisableInputs = Boolean(lodashGet(reimbursementAccount, ['achData.bankAccountID'])); diff --git a/src/pages/ReimbursementAccount/BankAccountPlaidStep.js b/src/pages/ReimbursementAccount/BankAccountPlaidStep.js index f78820a09c1b..d0c52fe5d236 100644 --- a/src/pages/ReimbursementAccount/BankAccountPlaidStep.js +++ b/src/pages/ReimbursementAccount/BankAccountPlaidStep.js @@ -72,8 +72,8 @@ function BankAccountPlaidStep(props) { ReimbursementAccount.updateReimbursementAccountDraft(bankAccountData); const bankAccountID = lodashGet(reimbursementAccount, 'achData.bankAccountID') || 0; - BankAccounts.connectBankAccountWithPlaid(bankAccountID, bankAccountData); - }, [reimbursementAccount, reimbursementAccountDraft, plaidData]); + BankAccounts.connectBankAccountWithPlaid(bankAccountID, bankAccountData, props.policyID); + }, [reimbursementAccount, reimbursementAccountDraft, plaidData, props.policyID]); const bankAccountID = lodashGet(reimbursementAccount, 'achData.bankAccountID') || 0; const selectedPlaidAccountID = lodashGet(reimbursementAccountDraft, 'plaidAccountID', ''); diff --git a/src/pages/ReimbursementAccount/CompanyStep.js b/src/pages/ReimbursementAccount/CompanyStep.js index 4ce3c44fb707..b636486193b3 100644 --- a/src/pages/ReimbursementAccount/CompanyStep.js +++ b/src/pages/ReimbursementAccount/CompanyStep.js @@ -152,7 +152,7 @@ class CompanyStep extends React.Component { companyPhone: parsePhoneNumber(values.companyPhone, {regionCode: CONST.COUNTRY.US}).number.significant, }; - BankAccounts.updateCompanyInformationForBankAccount(bankAccount); + BankAccounts.updateCompanyInformationForBankAccount(bankAccount, this.props.policyID); } render() { From 8e681a0a5d0a036d2b8af2a8f5469003ce674250 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 17 Jul 2023 16:08:24 -0600 Subject: [PATCH 3/5] use correct route path --- src/pages/ReimbursementAccount/ReimbursementAccountPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index c6a7274a1a4a..e91ee64b4f4e 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -330,7 +330,7 @@ class ReimbursementAccountPage extends React.Component { const achData = lodashGet(this.props.reimbursementAccount, 'achData', {}); const currentStep = achData.currentStep || CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT; const policyName = lodashGet(this.props.policy, 'name'); - const policyID = lodashGet(this.props.route, 'policyID'); + const policyID = lodashGet(this.props.route.params, 'policyID'); if (_.isEmpty(this.props.policy) || !Policy.isPolicyOwner(this.props.policy)) { return ( From 5a07ccabd7787d981148eed19bfd34c828f183ae Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 17 Jul 2023 16:13:20 -0600 Subject: [PATCH 4/5] update params in updateCompanyInformationForBankAccount --- src/libs/actions/BankAccounts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 8a76873207b2..65e945ae6ba7 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -332,7 +332,7 @@ function openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep) { * @param {String} policyID */ function updateCompanyInformationForBankAccount(bankAccount, policyID) { - API.write('UpdateCompanyInformationForBankAccount', {bankAccount, policyID}, getVBBADataForOnyx()); + API.write('UpdateCompanyInformationForBankAccount', {...bankAccount, policyID}, getVBBADataForOnyx()); } /** From bbf339c0198b57df63cd6f2e93015e2ac6decddc Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 17 Jul 2023 17:12:43 -0600 Subject: [PATCH 5/5] only pass param in CompanyStep --- src/libs/actions/BankAccounts.js | 8 ++------ src/pages/ReimbursementAccount/BankAccountManualStep.js | 3 +-- src/pages/ReimbursementAccount/BankAccountPlaidStep.js | 8 ++------ src/pages/ReimbursementAccount/BankAccountStep.js | 6 ------ .../ReimbursementAccount/ReimbursementAccountPage.js | 1 - 5 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 65e945ae6ba7..396cb83aee58 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -91,9 +91,8 @@ function getVBBADataForOnyx() { * * @param {Number} bankAccountID * @param {Object} selectedPlaidBankAccount - * @param {String} policyID */ -function connectBankAccountWithPlaid(bankAccountID, selectedPlaidBankAccount, policyID) { +function connectBankAccountWithPlaid(bankAccountID, selectedPlaidBankAccount) { const commandName = 'ConnectBankAccountWithPlaid'; const parameters = { @@ -103,7 +102,6 @@ function connectBankAccountWithPlaid(bankAccountID, selectedPlaidBankAccount, po bank: selectedPlaidBankAccount.bankName, plaidAccountID: selectedPlaidBankAccount.plaidAccountID, plaidAccessToken: selectedPlaidBankAccount.plaidAccessToken, - policyID, }; API.write(commandName, parameters, getVBBADataForOnyx()); @@ -358,10 +356,9 @@ function updateBeneficialOwnersForBankAccount(params) { * @param {String} [accountNumber] * @param {String} [routingNumber] * @param {String} [plaidMask] - * @param {String} policyID * */ -function connectBankAccountManually(bankAccountID, accountNumber, routingNumber, plaidMask, policyID) { +function connectBankAccountManually(bankAccountID, accountNumber, routingNumber, plaidMask) { API.write( 'ConnectBankAccountManually', { @@ -369,7 +366,6 @@ function connectBankAccountManually(bankAccountID, accountNumber, routingNumber, accountNumber, routingNumber, plaidMask, - policyID, }, getVBBADataForOnyx(), ); diff --git a/src/pages/ReimbursementAccount/BankAccountManualStep.js b/src/pages/ReimbursementAccount/BankAccountManualStep.js index 3894bbc3b562..fc692f388f5d 100644 --- a/src/pages/ReimbursementAccount/BankAccountManualStep.js +++ b/src/pages/ReimbursementAccount/BankAccountManualStep.js @@ -63,10 +63,9 @@ function BankAccountManualStep(props) { values.accountNumber, values.routingNumber, lodashGet(reimbursementAccountDraft, ['plaidMask']), - props.policyID, ); }, - [reimbursementAccount, reimbursementAccountDraft, props.policyID], + [reimbursementAccount, reimbursementAccountDraft], ); const shouldDisableInputs = Boolean(lodashGet(reimbursementAccount, ['achData.bankAccountID'])); diff --git a/src/pages/ReimbursementAccount/BankAccountPlaidStep.js b/src/pages/ReimbursementAccount/BankAccountPlaidStep.js index d0c52fe5d236..d74bea73eda0 100644 --- a/src/pages/ReimbursementAccount/BankAccountPlaidStep.js +++ b/src/pages/ReimbursementAccount/BankAccountPlaidStep.js @@ -30,16 +30,12 @@ const propTypes = { /** During the OAuth flow we need to use the plaidLink token that we initially connected with */ plaidLinkOAuthToken: PropTypes.string, - - /* The workspace policyID */ - policyID: PropTypes.string, }; const defaultProps = { plaidData: PlaidDataProps.plaidDataDefaultProps, receivedRedirectURI: null, plaidLinkOAuthToken: '', - policyID: '', }; function BankAccountPlaidStep(props) { @@ -72,8 +68,8 @@ function BankAccountPlaidStep(props) { ReimbursementAccount.updateReimbursementAccountDraft(bankAccountData); const bankAccountID = lodashGet(reimbursementAccount, 'achData.bankAccountID') || 0; - BankAccounts.connectBankAccountWithPlaid(bankAccountID, bankAccountData, props.policyID); - }, [reimbursementAccount, reimbursementAccountDraft, plaidData, props.policyID]); + BankAccounts.connectBankAccountWithPlaid(bankAccountID, bankAccountData); + }, [reimbursementAccount, reimbursementAccountDraft, plaidData]); const bankAccountID = lodashGet(reimbursementAccount, 'achData.bankAccountID') || 0; const selectedPlaidAccountID = lodashGet(reimbursementAccountDraft, 'plaidAccountID', ''); diff --git a/src/pages/ReimbursementAccount/BankAccountStep.js b/src/pages/ReimbursementAccount/BankAccountStep.js index 676b71350913..9617fbf46419 100644 --- a/src/pages/ReimbursementAccount/BankAccountStep.js +++ b/src/pages/ReimbursementAccount/BankAccountStep.js @@ -48,9 +48,6 @@ const propTypes = { /* The workspace name */ policyName: PropTypes.string, - - /* The workspace policyID */ - policyID: PropTypes.string, }; const defaultProps = { @@ -59,7 +56,6 @@ const defaultProps = { user: {}, isPlaidDisabled: false, policyName: '', - policyID: '', }; function BankAccountStep(props) { @@ -78,7 +74,6 @@ function BankAccountStep(props) { reimbursementAccountDraft={props.reimbursementAccountDraft} onBackButtonPress={props.onBackButtonPress} getDefaultStateForField={props.getDefaultStateForField} - policyID={props.policyID} /> ); } @@ -90,7 +85,6 @@ function BankAccountStep(props) { reimbursementAccountDraft={props.reimbursementAccountDraft} onBackButtonPress={props.onBackButtonPress} getDefaultStateForField={props.getDefaultStateForField} - policyID={props.policyID} /> ); } diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index e91ee64b4f4e..a07018ece1a9 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -413,7 +413,6 @@ class ReimbursementAccountPage extends React.Component { plaidLinkOAuthToken={this.props.plaidLinkToken} getDefaultStateForField={this.getDefaultStateForField} policyName={policyName} - policyID={policyID} /> ); }