@@ -86,6 +86,13 @@ type OpenPersonalBankAccountSetupViewProps = {
8686 isUserValidated ?: boolean ;
8787} ;
8888
89+ type VBBAOnyxKey =
90+ | typeof ONYXKEYS . REIMBURSEMENT_ACCOUNT
91+ | typeof ONYXKEYS . NVP_LAST_PAYMENT_METHOD
92+ | typeof ONYXKEYS . ONFIDO_TOKEN
93+ | typeof ONYXKEYS . ONFIDO_APPLICANT_ID
94+ | typeof ONYXKEYS . RAM_ONLY_PLAID_LINK_TOKEN ;
95+
8996function clearPlaid ( ) : Promise < void | void [ ] > {
9097 Onyx . set ( ONYXKEYS . RAM_ONLY_PLAID_LINK_TOKEN , '' ) ;
9198 Onyx . set ( ONYXKEYS . PLAID_CURRENT_EVENT , null ) ;
@@ -311,7 +318,35 @@ function updateAddPersonalBankAccountDraft(bankData: Partial<PersonalBankAccount
311318/**
312319 * Helper method to build the Onyx data required during setup of a Verified Business Bank Account
313320 */
314- function getVBBADataForOnyx ( currentStep ?: BankAccountStep , shouldShowLoading = true ) : OnyxData < typeof ONYXKEYS . REIMBURSEMENT_ACCOUNT | typeof ONYXKEYS . NVP_LAST_PAYMENT_METHOD > {
321+ function getVBBADataForOnyx ( currentStep ?: BankAccountStep , shouldShowLoading = true ) : OnyxData < VBBAOnyxKey > {
322+ const failureData : Array < OnyxUpdate < VBBAOnyxKey > > = [
323+ {
324+ onyxMethod : Onyx . METHOD . MERGE ,
325+ key : ONYXKEYS . REIMBURSEMENT_ACCOUNT ,
326+ value : {
327+ isLoading : false ,
328+ errors : getMicroSecondOnyxErrorWithTranslationKey ( 'walletPage.addBankAccountFailure' ) ,
329+ } ,
330+ } ,
331+ {
332+ onyxMethod : Onyx . METHOD . SET ,
333+ key : ONYXKEYS . RAM_ONLY_PLAID_LINK_TOKEN ,
334+ value : null ,
335+ } ,
336+ ] ;
337+ if ( currentStep !== CONST . BANK_ACCOUNT . STEP . REQUESTOR ) {
338+ failureData . push ( {
339+ onyxMethod : Onyx . METHOD . SET ,
340+ key : ONYXKEYS . ONFIDO_TOKEN ,
341+ value : null ,
342+ } ) ;
343+ failureData . push ( {
344+ onyxMethod : Onyx . METHOD . SET ,
345+ key : ONYXKEYS . ONFIDO_APPLICANT_ID ,
346+ value : null ,
347+ } ) ;
348+ }
349+
315350 return {
316351 optimisticData : [
317352 {
@@ -339,16 +374,7 @@ function getVBBADataForOnyx(currentStep?: BankAccountStep, shouldShowLoading = t
339374 } ,
340375 } ,
341376 ] ,
342- failureData : [
343- {
344- onyxMethod : Onyx . METHOD . MERGE ,
345- key : ONYXKEYS . REIMBURSEMENT_ACCOUNT ,
346- value : {
347- isLoading : false ,
348- errors : getMicroSecondOnyxErrorWithTranslationKey ( 'walletPage.addBankAccountFailure' ) ,
349- } ,
350- } ,
351- ] ,
377+ failureData,
352378 } ;
353379}
354380
@@ -359,10 +385,7 @@ function addBusinessWebsiteForDraft(websiteUrl: string) {
359385/**
360386 * Get the Onyx data required to set the last used payment method to VBBA for a given policyID
361387 */
362- function getOnyxDataForConnectingVBBAAndLastPaymentMethod (
363- policyID ?: string ,
364- lastPaymentMethod ?: LastPaymentMethodType | string ,
365- ) : OnyxData < typeof ONYXKEYS . REIMBURSEMENT_ACCOUNT | typeof ONYXKEYS . NVP_LAST_PAYMENT_METHOD > {
388+ function getOnyxDataForConnectingVBBAAndLastPaymentMethod ( policyID ?: string , lastPaymentMethod ?: LastPaymentMethodType | string ) : OnyxData < VBBAOnyxKey > {
366389 const onyxData = getVBBADataForOnyx ( ) ;
367390 const lastUsedPaymentMethod = typeof lastPaymentMethod === 'string' ? lastPaymentMethod : lastPaymentMethod ?. expense ?. name ;
368391
0 commit comments