diff --git a/src/libs/API/parameters/AcceptACHContractForBankAccount.ts b/src/libs/API/parameters/AcceptACHContractForBankAccount.ts index 6cf2735beabc..de4ce4e86857 100644 --- a/src/libs/API/parameters/AcceptACHContractForBankAccount.ts +++ b/src/libs/API/parameters/AcceptACHContractForBankAccount.ts @@ -1,5 +1,5 @@ import type {ACHContractStepProps} from '@src/types/form/ReimbursementAccountForm'; -type AcceptACHContractForBankAccount = ACHContractStepProps & {bankAccountID: number; canUseNewVbbaFlow?: boolean}; +type AcceptACHContractForBankAccount = ACHContractStepProps & {bankAccountID: number; policyID: string; canUseNewVbbaFlow?: boolean}; export default AcceptACHContractForBankAccount; diff --git a/src/libs/API/parameters/AddPersonalBankAccountParams.ts b/src/libs/API/parameters/AddPersonalBankAccountParams.ts index 1fa8fc0eb48d..d3caf65517df 100644 --- a/src/libs/API/parameters/AddPersonalBankAccountParams.ts +++ b/src/libs/API/parameters/AddPersonalBankAccountParams.ts @@ -1,8 +1,8 @@ type AddPersonalBankAccountParams = { - addressName: string; + addressName?: string; routingNumber: string; accountNumber: string; - isSavings: boolean; + isSavings?: boolean; setupType: string; bank?: string; plaidAccountID: string; diff --git a/src/libs/API/parameters/ConnectBankAccountManuallyParams.ts b/src/libs/API/parameters/ConnectBankAccountManuallyParams.ts deleted file mode 100644 index 17a72588a1e2..000000000000 --- a/src/libs/API/parameters/ConnectBankAccountManuallyParams.ts +++ /dev/null @@ -1,9 +0,0 @@ -type ConnectBankAccountManuallyParams = { - bankAccountID: number; - accountNumber?: string; - routingNumber?: string; - plaidMask?: string; - canUseNewVbbaFlow?: boolean; - policyID?: string; -}; -export default ConnectBankAccountManuallyParams; diff --git a/src/libs/API/parameters/ConnectBankAccountParams.ts b/src/libs/API/parameters/ConnectBankAccountParams.ts new file mode 100644 index 000000000000..fb0e3422d08c --- /dev/null +++ b/src/libs/API/parameters/ConnectBankAccountParams.ts @@ -0,0 +1,14 @@ +type ConnectBankAccountParams = { + bankAccountID: number; + routingNumber: string; + accountNumber: string; + bank?: string; + plaidAccountID?: string; + plaidAccessToken?: string; + plaidMask?: string; + isSavings?: boolean; + policyID?: string; + canUseNewVbbaFlow?: boolean; +}; + +export default ConnectBankAccountParams; diff --git a/src/libs/API/parameters/ConnectBankAccountWithPlaidParams.ts b/src/libs/API/parameters/ConnectBankAccountWithPlaidParams.ts deleted file mode 100644 index e41a3192420e..000000000000 --- a/src/libs/API/parameters/ConnectBankAccountWithPlaidParams.ts +++ /dev/null @@ -1,12 +0,0 @@ -type ConnectBankAccountWithPlaidParams = { - bankAccountID: number; - routingNumber: string; - accountNumber: string; - bank?: string; - plaidAccountID: string; - plaidAccessToken: string; - canUseNewVbbaFlow?: boolean; - policyID?: string; -}; - -export default ConnectBankAccountWithPlaidParams; diff --git a/src/libs/API/parameters/OpenReimbursementAccountPageParams.ts b/src/libs/API/parameters/OpenReimbursementAccountPageParams.ts index 5cd4bff2b94b..31eb443ce80e 100644 --- a/src/libs/API/parameters/OpenReimbursementAccountPageParams.ts +++ b/src/libs/API/parameters/OpenReimbursementAccountPageParams.ts @@ -7,8 +7,8 @@ type OpenReimbursementAccountPageParams = { stepToOpen: ReimbursementAccountStep; subStep: ReimbursementAccountSubStep; localCurrentStep: ReimbursementAccountStep; - policyID?: string; canUseNewVbbaFlow?: boolean; + policyID: string; }; export default OpenReimbursementAccountPageParams; diff --git a/src/libs/API/parameters/OpenWorkspaceViewParams.ts b/src/libs/API/parameters/OpenWorkspaceViewParams.ts new file mode 100644 index 000000000000..3dc9da6e1947 --- /dev/null +++ b/src/libs/API/parameters/OpenWorkspaceViewParams.ts @@ -0,0 +1,5 @@ +type OpenWorkspaceViewParams = { + policyID: string; +}; + +export default OpenWorkspaceViewParams; diff --git a/src/libs/API/parameters/UpdateBeneficialOwnersForBankAccountParams.ts b/src/libs/API/parameters/UpdateBeneficialOwnersForBankAccountParams.ts index 4d4e1af87e3b..f5cc3f664d12 100644 --- a/src/libs/API/parameters/UpdateBeneficialOwnersForBankAccountParams.ts +++ b/src/libs/API/parameters/UpdateBeneficialOwnersForBankAccountParams.ts @@ -1,5 +1,5 @@ -import type {ACHContractStepProps} from '@src/types/form/ReimbursementAccountForm'; +import type {BeneficialOwnersStepProps} from '@src/types/form/ReimbursementAccountForm'; -type UpdateBeneficialOwnersForBankAccountParams = ACHContractStepProps & {bankAccountID: number; canUseNewVbbaFlow?: boolean}; +type UpdateBeneficialOwnersForBankAccountParams = BeneficialOwnersStepProps & {bankAccountID: number; policyID: string; canUseNewVbbaFlow?: boolean}; export default UpdateBeneficialOwnersForBankAccountParams; diff --git a/src/libs/API/parameters/UpdateCompanyInformationForBankAccountParams.ts b/src/libs/API/parameters/UpdateCompanyInformationForBankAccountParams.ts index 324c7070bbe2..21ca49839aec 100644 --- a/src/libs/API/parameters/UpdateCompanyInformationForBankAccountParams.ts +++ b/src/libs/API/parameters/UpdateCompanyInformationForBankAccountParams.ts @@ -1,8 +1,5 @@ -import type {BankAccountStepProps, CompanyStepProps, ReimbursementAccountProps} from '@src/types/form/ReimbursementAccountForm'; +import type {CompanyStepProps} from '@src/types/form/ReimbursementAccountForm'; -type BankAccountCompanyInformation = BankAccountStepProps & CompanyStepProps & ReimbursementAccountProps; - -type UpdateCompanyInformationForBankAccountParams = BankAccountCompanyInformation & {bankAccountID: number; canUseNewVbbaFlow?: boolean}; +type UpdateCompanyInformationForBankAccountParams = CompanyStepProps & {bankAccountID: number; policyID: string; canUseNewVbbaFlow?: boolean}; export default UpdateCompanyInformationForBankAccountParams; -export type {BankAccountCompanyInformation}; diff --git a/src/libs/API/parameters/UpdatePersonalInformationForBankAccountParams.ts b/src/libs/API/parameters/UpdatePersonalInformationForBankAccountParams.ts index b9c2ce65405b..c1a29ddd9cec 100644 --- a/src/libs/API/parameters/UpdatePersonalInformationForBankAccountParams.ts +++ b/src/libs/API/parameters/UpdatePersonalInformationForBankAccountParams.ts @@ -1,5 +1,5 @@ import type {RequestorStepProps} from '@src/types/form/ReimbursementAccountForm'; -type UpdatePersonalInformationForBankAccountParams = RequestorStepProps & {bankAccountID: number; canUseNewVbbaFlow: boolean}; +type UpdatePersonalInformationForBankAccountParams = RequestorStepProps & {bankAccountID: number; policyID: string; canUseNewVbbaFlow: boolean}; export default UpdatePersonalInformationForBankAccountParams; diff --git a/src/libs/API/parameters/ValidateBankAccountWithTransactionsParams.ts b/src/libs/API/parameters/ValidateBankAccountWithTransactionsParams.ts index 546889b7a68e..dde8e6141a9d 100644 --- a/src/libs/API/parameters/ValidateBankAccountWithTransactionsParams.ts +++ b/src/libs/API/parameters/ValidateBankAccountWithTransactionsParams.ts @@ -1,6 +1,7 @@ type ValidateBankAccountWithTransactionsParams = { bankAccountID: number; validateCode: string; + policyID: string; }; export default ValidateBankAccountWithTransactionsParams; diff --git a/src/libs/API/parameters/VerifyIdentityForBankAccountParams.ts b/src/libs/API/parameters/VerifyIdentityForBankAccountParams.ts index 2104977e04d5..c11aec9be239 100644 --- a/src/libs/API/parameters/VerifyIdentityForBankAccountParams.ts +++ b/src/libs/API/parameters/VerifyIdentityForBankAccountParams.ts @@ -1,6 +1,7 @@ type VerifyIdentityForBankAccountParams = { bankAccountID: number; onfidoData: string; + policyID: string; canUseNewVbbaFlow?: boolean; }; export default VerifyIdentityForBankAccountParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index ada3b84e6cf4..4dd4ee3994fc 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -9,8 +9,7 @@ export type {default as BeginAppleSignInParams} from './BeginAppleSignInParams'; export type {default as BeginGoogleSignInParams} from './BeginGoogleSignInParams'; export type {default as BeginSignInParams} from './BeginSignInParams'; export type {default as CloseAccountParams} from './CloseAccountParams'; -export type {default as ConnectBankAccountManuallyParams} from './ConnectBankAccountManuallyParams'; -export type {default as ConnectBankAccountWithPlaidParams} from './ConnectBankAccountWithPlaidParams'; +export type {default as ConnectBankAccountParams} from './ConnectBankAccountParams'; export type {default as DeleteContactMethodParams} from './DeleteContactMethodParams'; export type {default as DeletePaymentBankAccountParams} from './DeletePaymentBankAccountParams'; export type {default as DeletePaymentCardParams} from './DeletePaymentCardParams'; @@ -109,6 +108,7 @@ export type {default as UpdateWorkspaceAvatarParams} from './UpdateWorkspaceAvat export type {default as AddMembersToWorkspaceParams} from './AddMembersToWorkspaceParams'; export type {default as DeleteMembersFromWorkspaceParams} from './DeleteMembersFromWorkspaceParams'; export type {default as OpenWorkspaceParams} from './OpenWorkspaceParams'; +export type {default as OpenWorkspaceViewParams} from './OpenWorkspaceViewParams'; export type {default as OpenWorkspaceReimburseViewParams} from './OpenWorkspaceReimburseViewParams'; export type {default as OpenWorkspaceInvitePageParams} from './OpenWorkspaceInvitePageParams'; export type {default as OpenWorkspaceMembersPageParams} from './OpenWorkspaceMembersPageParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 97e0fdd064c5..39ad71e6e9d6 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -160,7 +160,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.VALIDATE_BANK_ACCOUNT_WITH_TRANSACTIONS]: Parameters.ValidateBankAccountWithTransactionsParams; [WRITE_COMMANDS.UPDATE_COMPANY_INFORMATION_FOR_BANK_ACCOUNT]: Parameters.UpdateCompanyInformationForBankAccountParams; [WRITE_COMMANDS.UPDATE_BENEFICIAL_OWNERS_FOR_BANK_ACCOUNT]: UpdateBeneficialOwnersForBankAccountParams; - [WRITE_COMMANDS.CONNECT_BANK_ACCOUNT_MANUALLY]: Parameters.ConnectBankAccountManuallyParams; + [WRITE_COMMANDS.CONNECT_BANK_ACCOUNT_MANUALLY]: Parameters.ConnectBankAccountParams; [WRITE_COMMANDS.VERIFY_IDENTITY_FOR_BANK_ACCOUNT]: Parameters.VerifyIdentityForBankAccountParams; [WRITE_COMMANDS.BANK_ACCOUNT_HANDLE_PLAID_ERROR]: Parameters.BankAccountHandlePlaidErrorParams; [WRITE_COMMANDS.REPORT_VIRTUAL_EXPENSIFY_CARD_FRAUD]: Parameters.ReportVirtualExpensifyCardFraudParams; @@ -213,7 +213,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.TWO_FACTOR_AUTH_VALIDATE]: Parameters.ValidateTwoFactorAuthParams; [WRITE_COMMANDS.ADD_COMMENT]: Parameters.AddCommentOrAttachementParams; [WRITE_COMMANDS.ADD_ATTACHMENT]: Parameters.AddCommentOrAttachementParams; - [WRITE_COMMANDS.CONNECT_BANK_ACCOUNT_WITH_PLAID]: Parameters.ConnectBankAccountWithPlaidParams; + [WRITE_COMMANDS.CONNECT_BANK_ACCOUNT_WITH_PLAID]: Parameters.ConnectBankAccountParams; [WRITE_COMMANDS.ADD_PERSONAL_BANK_ACCOUNT]: Parameters.AddPersonalBankAccountParams; [WRITE_COMMANDS.OPT_IN_TO_PUSH_NOTIFICATIONS]: Parameters.OptInOutToPushNotificationsParams; [WRITE_COMMANDS.OPT_OUT_OF_PUSH_NOTIFICATIONS]: Parameters.OptInOutToPushNotificationsParams; @@ -325,7 +325,7 @@ type ReadCommand = ValueOf; type ReadCommandParameters = { [READ_COMMANDS.OPEN_APP]: Parameters.OpenAppParams; [READ_COMMANDS.OPEN_REIMBURSEMENT_ACCOUNT_PAGE]: Parameters.OpenReimbursementAccountPageParams; - [READ_COMMANDS.OPEN_WORKSPACE_VIEW]: EmptyObject; + [READ_COMMANDS.OPEN_WORKSPACE_VIEW]: Parameters.OpenWorkspaceViewParams; [READ_COMMANDS.GET_MAPBOX_ACCESS_TOKEN]: EmptyObject; [READ_COMMANDS.OPEN_PAYMENTS_PAGE]: EmptyObject; [READ_COMMANDS.OPEN_PERSONAL_DETAILS]: EmptyObject; diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index c5f68317bf18..30dd03b6e780 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -3,8 +3,7 @@ import * as API from '@libs/API'; import type { AddPersonalBankAccountParams, BankAccountHandlePlaidErrorParams, - ConnectBankAccountManuallyParams, - ConnectBankAccountWithPlaidParams, + ConnectBankAccountParams, DeletePaymentBankAccountParams, OpenReimbursementAccountPageParams, ValidateBankAccountWithTransactionsParams, @@ -152,13 +151,15 @@ function addBusinessWebsiteForDraft(websiteUrl: string) { * Submit Bank Account step with Plaid data so php can perform some checks. */ function connectBankAccountWithPlaid(bankAccountID: number, selectedPlaidBankAccount: PlaidBankAccount, policyID: string) { - const parameters: ConnectBankAccountWithPlaidParams = { + const parameters: ConnectBankAccountParams = { bankAccountID, routingNumber: selectedPlaidBankAccount.routingNumber, accountNumber: selectedPlaidBankAccount.accountNumber, bank: selectedPlaidBankAccount.bankName, plaidAccountID: selectedPlaidBankAccount.plaidAccountID, plaidAccessToken: selectedPlaidBankAccount.plaidAccessToken, + plaidMask: selectedPlaidBankAccount.mask, + isSavings: selectedPlaidBankAccount.isSavings, canUseNewVbbaFlow: true, policyID, }; @@ -254,22 +255,24 @@ function deletePaymentBankAccount(bankAccountID: number) { * @param bankAccountID - ID for bank account * @param params - User personal data */ -function updatePersonalInformationForBankAccount(bankAccountID: number, params: RequestorStepProps) { +function updatePersonalInformationForBankAccount(bankAccountID: number, params: RequestorStepProps, policyID: string) { API.write( WRITE_COMMANDS.UPDATE_PERSONAL_INFORMATION_FOR_BANK_ACCOUNT, { ...params, bankAccountID, + policyID, canUseNewVbbaFlow: true, }, getVBBADataForOnyx(CONST.BANK_ACCOUNT.STEP.REQUESTOR), ); } -function validateBankAccount(bankAccountID: number, validateCode: string) { +function validateBankAccount(bankAccountID: number, validateCode: string, policyID: string) { const parameters: ValidateBankAccountWithTransactionsParams = { bankAccountID, validateCode, + policyID, }; const onyxData: OnyxData = { @@ -363,12 +366,13 @@ function openReimbursementAccountPage(stepToOpen: ReimbursementAccountStep, subS * Updates the bank account in the database with the company step data * @param params - Business step form data */ -function updateCompanyInformationForBankAccount(bankAccountID: number, params: CompanyStepProps) { +function updateCompanyInformationForBankAccount(bankAccountID: number, params: CompanyStepProps, policyID: string) { API.write( WRITE_COMMANDS.UPDATE_COMPANY_INFORMATION_FOR_BANK_ACCOUNT, { ...params, bankAccountID, + policyID, canUseNewVbbaFlow: true, }, getVBBADataForOnyx(CONST.BANK_ACCOUNT.STEP.COMPANY), @@ -379,12 +383,13 @@ function updateCompanyInformationForBankAccount(bankAccountID: number, params: C * Add beneficial owners for the bank account and verify the accuracy of the information provided * @param params - Beneficial Owners step form params */ -function updateBeneficialOwnersForBankAccount(bankAccountID: number, params: BeneficialOwnersStepProps) { +function updateBeneficialOwnersForBankAccount(bankAccountID: number, params: BeneficialOwnersStepProps, policyID: string) { API.write( WRITE_COMMANDS.UPDATE_BENEFICIAL_OWNERS_FOR_BANK_ACCOUNT, { ...params, bankAccountID, + policyID, canUseNewVbbaFlow: true, }, getVBBADataForOnyx(), @@ -395,12 +400,13 @@ function updateBeneficialOwnersForBankAccount(bankAccountID: number, params: Ben * Accept the ACH terms and conditions and verify the accuracy of the information provided * @param params - Verification step form params */ -function acceptACHContractForBankAccount(bankAccountID: number, params: ACHContractStepProps) { +function acceptACHContractForBankAccount(bankAccountID: number, params: ACHContractStepProps, policyID: string) { API.write( WRITE_COMMANDS.ACCEPT_ACH_CONTRACT_FOR_BANK_ACCOUNT, { ...params, bankAccountID, + policyID, canUseNewVbbaFlow: true, }, getVBBADataForOnyx(), @@ -409,14 +415,17 @@ function acceptACHContractForBankAccount(bankAccountID: number, params: ACHContr /** * Create the bank account with manually entered data. - * @param plaidMask - scheme for Plaid account number */ -function connectBankAccountManually(bankAccountID: number, accountNumber?: string, routingNumber?: string, plaidMask?: string, policyID?: string) { - const parameters: ConnectBankAccountManuallyParams = { +function connectBankAccountManually(bankAccountID: number, bankAccount: PlaidBankAccount, policyID: string) { + const parameters: ConnectBankAccountParams = { bankAccountID, - accountNumber, - routingNumber, - plaidMask, + routingNumber: bankAccount.routingNumber, + accountNumber: bankAccount.accountNumber, + bank: bankAccount.bankName, + plaidAccountID: bankAccount.plaidAccountID, + plaidAccessToken: bankAccount.plaidAccessToken, + plaidMask: bankAccount.mask, + isSavings: bankAccount.isSavings, canUseNewVbbaFlow: true, policyID, }; @@ -427,20 +436,23 @@ function connectBankAccountManually(bankAccountID: number, accountNumber?: strin /** * Verify the user's identity via Onfido */ -function verifyIdentityForBankAccount(bankAccountID: number, onfidoData: Record) { +function verifyIdentityForBankAccount(bankAccountID: number, onfidoData: Record, policyID: string) { const parameters: VerifyIdentityForBankAccountParams = { bankAccountID, onfidoData: JSON.stringify(onfidoData), + policyID, canUseNewVbbaFlow: true, }; API.write(WRITE_COMMANDS.VERIFY_IDENTITY_FOR_BANK_ACCOUNT, parameters, getVBBADataForOnyx()); } -function openWorkspaceView() { +function openWorkspaceView(policyID: string) { API.read( READ_COMMANDS.OPEN_WORKSPACE_VIEW, - {}, + { + policyID, + }, { optimisticData: [ { diff --git a/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.js b/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.js index 962800fb2e55..2cc085e32f5e 100644 --- a/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.js +++ b/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.js @@ -9,8 +9,9 @@ import ONYXKEYS from '@src/ONYXKEYS'; * Reset user's reimbursement account. This will delete the bank account. * @param {Number} bankAccountID * @param {Object} session + * @param {String} policyID */ -function resetFreePlanBankAccount(bankAccountID, session) { +function resetFreePlanBankAccount(bankAccountID, session, policyID) { if (!bankAccountID) { throw new Error('Missing bankAccountID when attempting to reset free plan bank account'); } @@ -23,6 +24,7 @@ function resetFreePlanBankAccount(bankAccountID, session) { { bankAccountID, ownerEmail: session.email, + policyID, }, { optimisticData: [ diff --git a/src/pages/ReimbursementAccount/BankAccountStep.js b/src/pages/ReimbursementAccount/BankAccountStep.js index 278036430dbf..75ae02587486 100644 --- a/src/pages/ReimbursementAccount/BankAccountStep.js +++ b/src/pages/ReimbursementAccount/BankAccountStep.js @@ -97,7 +97,12 @@ function BankAccountStep(props) { }; if (subStep === CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID || subStep === CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL) { - return ; + return ( + + ); } return ( diff --git a/src/pages/ReimbursementAccount/BankInfo/BankInfo.tsx b/src/pages/ReimbursementAccount/BankInfo/BankInfo.tsx index a0b91ffcdb0e..bb352acd4732 100644 --- a/src/pages/ReimbursementAccount/BankInfo/BankInfo.tsx +++ b/src/pages/ReimbursementAccount/BankInfo/BankInfo.tsx @@ -31,6 +31,8 @@ type BankInfoOnyxProps = { /** The draft values of the bank account being setup */ reimbursementAccountDraft: OnyxEntry; + + policyID: string; }; type BankInfoProps = BankInfoOnyxProps & { @@ -43,7 +45,7 @@ const manualSubsteps: Array> = [Manual, Confir const plaidSubsteps: Array> = [Plaid, Confirmation]; const receivedRedirectURI = getPlaidOAuthReceivedRedirectURI(); -function BankInfo({reimbursementAccount, reimbursementAccountDraft, plaidLinkToken, onBackButtonPress}: BankInfoProps) { +function BankInfo({reimbursementAccount, reimbursementAccountDraft, plaidLinkToken, onBackButtonPress, policyID}: BankInfoProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); @@ -57,15 +59,20 @@ function BankInfo({reimbursementAccount, reimbursementAccountDraft, plaidLinkTok setupType = CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID; } - const policyID = reimbursementAccount?.achData?.policyID ?? ''; const bankAccountID = Number(reimbursementAccount?.achData?.bankAccountID ?? '0'); const submit = useCallback(() => { if (setupType === CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL) { BankAccounts.connectBankAccountManually( bankAccountID, - values[BANK_INFO_STEP_KEYS.ACCOUNT_NUMBER], - values[BANK_INFO_STEP_KEYS.ROUTING_NUMBER], - values[BANK_INFO_STEP_KEYS.PLAID_MASK], + { + [BANK_INFO_STEP_KEYS.ROUTING_NUMBER]: values[BANK_INFO_STEP_KEYS.ROUTING_NUMBER] ?? '', + [BANK_INFO_STEP_KEYS.ACCOUNT_NUMBER]: values[BANK_INFO_STEP_KEYS.ACCOUNT_NUMBER] ?? '', + [BANK_INFO_STEP_KEYS.BANK_NAME]: values[BANK_INFO_STEP_KEYS.BANK_NAME] ?? '', + [BANK_INFO_STEP_KEYS.PLAID_ACCOUNT_ID]: values[BANK_INFO_STEP_KEYS.PLAID_ACCOUNT_ID] ?? '', + [BANK_INFO_STEP_KEYS.PLAID_ACCESS_TOKEN]: values[BANK_INFO_STEP_KEYS.PLAID_ACCESS_TOKEN] ?? '', + [BANK_INFO_STEP_KEYS.PLAID_MASK]: values[BANK_INFO_STEP_KEYS.PLAID_MASK] ?? '', + [BANK_INFO_STEP_KEYS.IS_SAVINGS]: values[BANK_INFO_STEP_KEYS.IS_SAVINGS] ?? false, + }, policyID, ); } else if (setupType === CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID) { @@ -77,6 +84,8 @@ function BankInfo({reimbursementAccount, reimbursementAccountDraft, plaidLinkTok [BANK_INFO_STEP_KEYS.BANK_NAME]: values[BANK_INFO_STEP_KEYS.BANK_NAME] ?? '', [BANK_INFO_STEP_KEYS.PLAID_ACCOUNT_ID]: values[BANK_INFO_STEP_KEYS.PLAID_ACCOUNT_ID] ?? '', [BANK_INFO_STEP_KEYS.PLAID_ACCESS_TOKEN]: values[BANK_INFO_STEP_KEYS.PLAID_ACCESS_TOKEN] ?? '', + [BANK_INFO_STEP_KEYS.PLAID_MASK]: values[BANK_INFO_STEP_KEYS.PLAID_MASK] ?? '', + [BANK_INFO_STEP_KEYS.IS_SAVINGS]: values[BANK_INFO_STEP_KEYS.IS_SAVINGS] ?? false, }, policyID, ); diff --git a/src/pages/ReimbursementAccount/BeneficialOwnersStep.tsx b/src/pages/ReimbursementAccount/BeneficialOwnersStep.tsx index 406033b10b03..10b05e58deb7 100644 --- a/src/pages/ReimbursementAccount/BeneficialOwnersStep.tsx +++ b/src/pages/ReimbursementAccount/BeneficialOwnersStep.tsx @@ -47,6 +47,7 @@ function BeneficialOwnersStep({reimbursementAccount, reimbursementAccountDraft, const {translate} = useLocalize(); const styles = useThemeStyles(); const companyName = reimbursementAccount?.achData?.companyName ?? ''; + const policyID = reimbursementAccount?.achData?.policyID ?? ''; const defaultValues = { ownsMoreThan25Percent: reimbursementAccount?.achData?.ownsMoreThan25Percent ?? reimbursementAccountDraft?.ownsMoreThan25Percent ?? false, hasOtherBeneficialOwners: reimbursementAccount?.achData?.hasOtherBeneficialOwners ?? reimbursementAccountDraft?.hasOtherBeneficialOwners ?? false, @@ -76,11 +77,15 @@ function BeneficialOwnersStep({reimbursementAccount, reimbursementAccountDraft, ), ); - BankAccounts.updateBeneficialOwnersForBankAccount(Number(reimbursementAccount?.achData?.bankAccountID ?? '0'), { - ownsMoreThan25Percent: isUserUBO, - beneficialOwners: JSON.stringify(beneficialOwners), - beneficialOwnerKeys, - }); + BankAccounts.updateBeneficialOwnersForBankAccount( + Number(reimbursementAccount?.achData?.bankAccountID ?? '0'), + { + ownsMoreThan25Percent: isUserUBO, + beneficialOwners: JSON.stringify(beneficialOwners), + beneficialOwnerKeys, + }, + policyID, + ); }; const addBeneficialOwner = (beneficialOwnerID: string) => { diff --git a/src/pages/ReimbursementAccount/BusinessInfo/BusinessInfo.tsx b/src/pages/ReimbursementAccount/BusinessInfo/BusinessInfo.tsx index 21f90c414b5d..f63cf72f8a4f 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/BusinessInfo.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/BusinessInfo.tsx @@ -68,16 +68,21 @@ function BusinessInfo({reimbursementAccount, reimbursementAccountDraft, onBackBu [reimbursementAccount, reimbursementAccountDraft], ); + const policyID = reimbursementAccount?.achData?.policyID ?? ''; const values = useMemo(() => getSubstepValues(BUSINESS_INFO_STEP_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); const submit = useCallback(() => { - BankAccounts.updateCompanyInformationForBankAccount(Number(reimbursementAccount?.achData?.bankAccountID ?? '0'), { - ...values, - ...getBankAccountFields(['routingNumber', 'accountNumber', 'bankName', 'plaidAccountID', 'plaidAccessToken', 'isSavings']), - companyTaxID: values.companyTaxID?.replace(CONST.REGEX.NON_NUMERIC, ''), - companyPhone: parsePhoneNumber(values.companyPhone ?? '', {regionCode: CONST.COUNTRY.US}).number?.significant, - }); - }, [reimbursementAccount, values, getBankAccountFields]); + BankAccounts.updateCompanyInformationForBankAccount( + Number(reimbursementAccount?.achData?.bankAccountID ?? '0'), + { + ...values, + ...getBankAccountFields(['routingNumber', 'accountNumber', 'bankName', 'plaidAccountID', 'plaidAccessToken', 'isSavings']), + companyTaxID: values.companyTaxID?.replace(CONST.REGEX.NON_NUMERIC, ''), + companyPhone: parsePhoneNumber(values.companyPhone ?? '', {regionCode: CONST.COUNTRY.US}).number?.significant, + }, + policyID, + ); + }, [reimbursementAccount, values, getBankAccountFields, policyID]); const startFrom = useMemo(() => getInitialSubstepForBusinessInfo(values), [values]); diff --git a/src/pages/ReimbursementAccount/CompleteVerification/CompleteVerification.tsx b/src/pages/ReimbursementAccount/CompleteVerification/CompleteVerification.tsx index 20d4663dcf8d..1c440a52644c 100644 --- a/src/pages/ReimbursementAccount/CompleteVerification/CompleteVerification.tsx +++ b/src/pages/ReimbursementAccount/CompleteVerification/CompleteVerification.tsx @@ -40,14 +40,19 @@ function CompleteVerification({reimbursementAccount, reimbursementAccountDraft, const styles = useThemeStyles(); const values = useMemo(() => getSubstepValues(COMPLETE_VERIFICATION_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); + const policyID = reimbursementAccount?.achData?.policyID ?? ''; const submit = useCallback(() => { - BankAccounts.acceptACHContractForBankAccount(Number(reimbursementAccount?.achData?.bankAccountID ?? '0'), { - isAuthorizedToUseBankAccount: values.isAuthorizedToUseBankAccount, - certifyTrueInformation: values.certifyTrueInformation, - acceptTermsAndConditions: values.acceptTermsAndConditions, - }); - }, [reimbursementAccount, values]); + BankAccounts.acceptACHContractForBankAccount( + Number(reimbursementAccount?.achData?.bankAccountID ?? '0'), + { + isAuthorizedToUseBankAccount: values.isAuthorizedToUseBankAccount, + certifyTrueInformation: values.certifyTrueInformation, + acceptTermsAndConditions: values.acceptTermsAndConditions, + }, + policyID, + ); + }, [reimbursementAccount, values, policyID]); const {componentToRender: SubStep, isEditing, screenIndex, nextScreen, prevScreen, moveTo, goToTheLastStep} = useSubStep({bodyContent, startFrom: 0, onFinished: submit}); diff --git a/src/pages/ReimbursementAccount/ConnectBankAccount/components/BankAccountValidationForm.tsx b/src/pages/ReimbursementAccount/ConnectBankAccount/components/BankAccountValidationForm.tsx index d921343c9557..0e8192b60416 100644 --- a/src/pages/ReimbursementAccount/ConnectBankAccount/components/BankAccountValidationForm.tsx +++ b/src/pages/ReimbursementAccount/ConnectBankAccount/components/BankAccountValidationForm.tsx @@ -89,10 +89,10 @@ function BankAccountValidationForm({requiresTwoFactorAuth, reimbursementAccount, // Send valid amounts to BankAccountAPI::validateBankAccount in Web-Expensify const bankAccountID = Number(reimbursementAccount?.achData?.bankAccountID ?? '0'); if (bankAccountID) { - BankAccounts.validateBankAccount(bankAccountID, validateCode); + BankAccounts.validateBankAccount(bankAccountID, validateCode, policyID); } }, - [reimbursementAccount], + [reimbursementAccount, policyID], ); return ( getSubstepValues(PERSONAL_INFO_STEP_KEYS, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); const bankAccountID = Number(reimbursementAccount?.achData?.bankAccountID ?? '0'); const submit = useCallback(() => { - BankAccounts.updatePersonalInformationForBankAccount(bankAccountID, {...values}); - }, [values, bankAccountID]); + BankAccounts.updatePersonalInformationForBankAccount(bankAccountID, {...values}, policyID); + }, [values, bankAccountID, policyID]); const startFrom = useMemo(() => getInitialSubstepForPersonalInfo(values), [values]); const {componentToRender: SubStep, isEditing, screenIndex, nextScreen, prevScreen, moveTo, goToTheLastStep} = useSubStep({bodyContent, startFrom, onFinished: submit}); diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountDraftPropTypes.js b/src/pages/ReimbursementAccount/ReimbursementAccountDraftPropTypes.js index c46ae5a65020..97bd1c508775 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountDraftPropTypes.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountDraftPropTypes.js @@ -8,7 +8,7 @@ export default PropTypes.shape({ routingNumber: PropTypes.string, acceptTerms: PropTypes.bool, plaidAccountID: PropTypes.string, - plaidMask: PropTypes.string, + mask: PropTypes.string, /** Props needed for CompanyStep */ companyName: PropTypes.string, diff --git a/src/pages/ReimbursementAccount/VerifyIdentity/VerifyIdentity.tsx b/src/pages/ReimbursementAccount/VerifyIdentity/VerifyIdentity.tsx index 44563afd587c..d17166365a39 100644 --- a/src/pages/ReimbursementAccount/VerifyIdentity/VerifyIdentity.tsx +++ b/src/pages/ReimbursementAccount/VerifyIdentity/VerifyIdentity.tsx @@ -38,12 +38,13 @@ function VerifyIdentity({reimbursementAccount, onBackButtonPress, onfidoApplican const styles = useThemeStyles(); const {translate} = useLocalize(); + const policyID = reimbursementAccount?.achData?.policyID ?? ''; const handleOnfidoSuccess = useCallback( (onfidoData: Record) => { - BankAccounts.verifyIdentityForBankAccount(Number(reimbursementAccount?.achData?.bankAccountID ?? '0'), {...onfidoData, applicantID: onfidoApplicantID}); + BankAccounts.verifyIdentityForBankAccount(Number(reimbursementAccount?.achData?.bankAccountID ?? '0'), {...onfidoData, applicantID: onfidoApplicantID}, policyID); BankAccounts.updateReimbursementAccountDraft({isOnfidoSetupComplete: true}); }, - [reimbursementAccount, onfidoApplicantID], + [reimbursementAccount, onfidoApplicantID, policyID], ); const handleOnfidoError = () => { diff --git a/src/pages/workspace/WorkspacePageWithSections.tsx b/src/pages/workspace/WorkspacePageWithSections.tsx index 9e01a82b3188..4a77adac7b37 100644 --- a/src/pages/workspace/WorkspacePageWithSections.tsx +++ b/src/pages/workspace/WorkspacePageWithSections.tsx @@ -79,12 +79,12 @@ type WorkspacePageWithSectionsProps = WithPolicyAndFullscreenLoadingProps & icon?: IconAsset; }; -function fetchData(skipVBBACal?: boolean) { +function fetchData(policyID: string, skipVBBACal?: boolean) { if (skipVBBACal) { return; } - BankAccounts.openWorkspaceView(); + BankAccounts.openWorkspaceView(policyID); } function WorkspacePageWithSections({ @@ -107,12 +107,12 @@ function WorkspacePageWithSections({ icon, }: WorkspacePageWithSectionsProps) { const styles = useThemeStyles(); - useNetwork({onReconnect: () => fetchData(shouldSkipVBBACall)}); + const policyID = route.params?.policyID ?? ''; + useNetwork({onReconnect: () => fetchData(policyID, shouldSkipVBBACall)}); const isLoading = reimbursementAccount?.isLoading ?? true; const achState = reimbursementAccount?.achData?.state ?? ''; const isUsingECard = user?.isUsingExpensifyCard ?? false; - const policyID = route.params?.policyID ?? ''; const hasVBA = achState === BankAccount.STATE.OPEN; const content = children(hasVBA, policyID, isUsingECard); const {isSmallScreenWidth} = useWindowDimensions(); @@ -131,8 +131,8 @@ function WorkspacePageWithSections({ }, []); useEffect(() => { - fetchData(shouldSkipVBBACall); - }, [shouldSkipVBBACall]); + fetchData(policyID, shouldSkipVBBACall); + }, [policyID, shouldSkipVBBACall]); const shouldShow = useMemo(() => { // If the policy object doesn't exist or contains only error data, we shouldn't display it. diff --git a/src/pages/workspace/WorkspaceResetBankAccountModal.js b/src/pages/workspace/WorkspaceResetBankAccountModal.js index f4ad662ebb75..f98077a546ca 100644 --- a/src/pages/workspace/WorkspaceResetBankAccountModal.js +++ b/src/pages/workspace/WorkspaceResetBankAccountModal.js @@ -48,7 +48,7 @@ function WorkspaceResetBankAccountModal({reimbursementAccount, session}) { } danger onCancel={BankAccounts.cancelResetFreePlanBankAccount} - onConfirm={() => BankAccounts.resetFreePlanBankAccount(bankAccountID, session)} + onConfirm={() => BankAccounts.resetFreePlanBankAccount(bankAccountID, session, achData.policyID)} shouldShowCancelButton isVisible /> diff --git a/src/types/form/ReimbursementAccountForm.ts b/src/types/form/ReimbursementAccountForm.ts index ff45795992c4..7bc1c52e8025 100644 --- a/src/types/form/ReimbursementAccountForm.ts +++ b/src/types/form/ReimbursementAccountForm.ts @@ -4,7 +4,7 @@ const INPUT_IDS = { BANK_INFO_STEP: { ROUTING_NUMBER: 'routingNumber', ACCOUNT_NUMBER: 'accountNumber', - PLAID_MASK: 'plaidMask', + PLAID_MASK: 'mask', IS_SAVINGS: 'isSavings', BANK_NAME: 'bankName', PLAID_ACCOUNT_ID: 'plaidAccountID', diff --git a/src/types/onyx/PlaidBankAccount.ts b/src/types/onyx/PlaidBankAccount.ts index f0aa5f8540e1..7620c4aee367 100644 --- a/src/types/onyx/PlaidBankAccount.ts +++ b/src/types/onyx/PlaidBankAccount.ts @@ -15,7 +15,7 @@ type PlaidBankAccount = { routingNumber: string; /** Last 4 digits of the account number */ - mask?: string; + mask: string; /** Plaid access token, used to then retrieve Assets and Balances */ plaidAccessToken: string;