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

Add missing params in vbba setup flow and clean up #36689

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions src/libs/API/parameters/AddPersonalBankAccountParams.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
type AddPersonalBankAccountParams = {
addressName: string;
addressName?: string;
routingNumber: string;
accountNumber: string;
isSavings: boolean;
isSavings?: boolean;
setupType: string;
bank?: string;
plaidAccountID: string;
Expand Down
9 changes: 0 additions & 9 deletions src/libs/API/parameters/ConnectBankAccountManuallyParams.ts

This file was deleted.

14 changes: 14 additions & 0 deletions src/libs/API/parameters/ConnectBankAccountParams.ts
Original file line number Diff line number Diff line change
@@ -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;
12 changes: 0 additions & 12 deletions src/libs/API/parameters/ConnectBankAccountWithPlaidParams.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ type OpenReimbursementAccountPageParams = {
stepToOpen: ReimbursementAccountStep;
subStep: ReimbursementAccountSubStep;
localCurrentStep: ReimbursementAccountStep;
policyID?: string;
canUseNewVbbaFlow?: boolean;
policyID: string;
};

export default OpenReimbursementAccountPageParams;
5 changes: 5 additions & 0 deletions src/libs/API/parameters/OpenWorkspaceViewParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type OpenWorkspaceViewParams = {
policyID: string;
};

export default OpenWorkspaceViewParams;
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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};
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
type ValidateBankAccountWithTransactionsParams = {
bankAccountID: number;
validateCode: string;
policyID: string;
};

export default ValidateBankAccountWithTransactionsParams;
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
type VerifyIdentityForBankAccountParams = {
bankAccountID: number;
onfidoData: string;
policyID: string;
canUseNewVbbaFlow?: boolean;
};
export default VerifyIdentityForBankAccountParams;
4 changes: 2 additions & 2 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down
6 changes: 3 additions & 3 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -325,7 +325,7 @@ type ReadCommand = ValueOf<typeof READ_COMMANDS>;
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;
Expand Down
46 changes: 29 additions & 17 deletions src/libs/actions/BankAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import * as API from '@libs/API';
import type {
AddPersonalBankAccountParams,
BankAccountHandlePlaidErrorParams,
ConnectBankAccountManuallyParams,
ConnectBankAccountWithPlaidParams,
ConnectBankAccountParams,
DeletePaymentBankAccountParams,
OpenReimbursementAccountPageParams,
ValidateBankAccountWithTransactionsParams,
Expand Down Expand Up @@ -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,
};
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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),
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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,
hayata-suenaga marked this conversation as resolved.
Show resolved Hide resolved
bank: bankAccount.bankName,
plaidAccountID: bankAccount.plaidAccountID,
plaidAccessToken: bankAccount.plaidAccessToken,
plaidMask: bankAccount.mask,
isSavings: bankAccount.isSavings,
canUseNewVbbaFlow: true,
policyID,
};
Expand All @@ -427,20 +436,23 @@ function connectBankAccountManually(bankAccountID: number, accountNumber?: strin
/**
* Verify the user's identity via Onfido
*/
function verifyIdentityForBankAccount(bankAccountID: number, onfidoData: Record<string, unknown>) {
function verifyIdentityForBankAccount(bankAccountID: number, onfidoData: Record<string, unknown>, 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: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand All @@ -23,6 +24,7 @@ function resetFreePlanBankAccount(bankAccountID, session) {
{
bankAccountID,
ownerEmail: session.email,
policyID,
},
{
optimisticData: [
Expand Down
7 changes: 6 additions & 1 deletion src/pages/ReimbursementAccount/BankAccountStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ function BankAccountStep(props) {
};

if (subStep === CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID || subStep === CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL) {
return <BankInfo onBackButtonPress={props.onBackButtonPress} />;
return (
<BankInfo
onBackButtonPress={props.onBackButtonPress}
policyID={props.policyID}
/>
);
}

return (
Expand Down
19 changes: 14 additions & 5 deletions src/pages/ReimbursementAccount/BankInfo/BankInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type BankInfoOnyxProps = {

/** The draft values of the bank account being setup */
reimbursementAccountDraft: OnyxEntry<ReimbursementAccountForm>;

policyID: string;
};

type BankInfoProps = BankInfoOnyxProps & {
Expand All @@ -43,7 +45,7 @@ const manualSubsteps: Array<React.ComponentType<SubStepProps>> = [Manual, Confir
const plaidSubsteps: Array<React.ComponentType<SubStepProps>> = [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();

Expand All @@ -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) {
Expand All @@ -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,
);
Expand Down
Loading
Loading