@@ -5,20 +5,19 @@ import type {EmitterSubscription, GestureResponderEvent, View} from 'react-nativ
55import AddPaymentMethodMenu from '@components/AddPaymentMethodMenu' ;
66import useOnyx from '@hooks/useOnyx' ;
77import { openPersonalBankAccountSetupView } from '@libs/actions/BankAccounts' ;
8- import { completePaymentOnboarding , savePreferredPaymentMethod } from '@libs/actions/IOU' ;
9- import { moveIOUReportToPolicy , moveIOUReportToPolicyAndInviteSubmitter } from '@libs/actions/Report' ;
8+ import { completePaymentOnboarding } from '@libs/actions/IOU' ;
109import getClickedTargetLocation from '@libs/getClickedTargetLocation' ;
1110import Log from '@libs/Log' ;
1211import Navigation from '@libs/Navigation/Navigation' ;
1312import { hasExpensifyPaymentMethod } from '@libs/PaymentUtils' ;
14- import { getPolicyExpenseChat , isExpenseReport as isExpenseReportReportUtils , isIOUReport } from '@libs/ReportUtils' ;
13+ import { isExpenseReport as isExpenseReportReportUtils , isIOUReport } from '@libs/ReportUtils' ;
1514import { kycWallRef } from '@userActions/PaymentMethods' ;
1615import { createWorkspaceFromIOUPayment } from '@userActions/Policy/Policy' ;
1716import { setKYCWallSource } from '@userActions/Wallet' ;
1817import CONST from '@src/CONST' ;
1918import ONYXKEYS from '@src/ONYXKEYS' ;
2019import ROUTES from '@src/ROUTES' ;
21- import type { BankAccountList , Policy } from '@src/types/onyx' ;
20+ import type { BankAccountList } from '@src/types/onyx' ;
2221import type { PaymentMethodType } from '@src/types/onyx/OriginalMessage' ;
2322import { getEmptyObject } from '@src/types/utils/EmptyObject' ;
2423import viewRef from '@src/types/utils/viewRef' ;
@@ -103,48 +102,24 @@ function KYCWall({
103102 } , [ getAnchorPosition ] ) ;
104103
105104 const selectPaymentMethod = useCallback (
106- ( paymentMethod ?: PaymentMethod , policy ?: Policy ) => {
107- if ( paymentMethod ) {
108- onSelectPaymentMethod ( paymentMethod ) ;
109- }
105+ ( paymentMethod : PaymentMethod ) => {
106+ onSelectPaymentMethod ( paymentMethod ) ;
110107
111108 if ( paymentMethod === CONST . PAYMENT_METHODS . PERSONAL_BANK_ACCOUNT ) {
112109 openPersonalBankAccountSetupView ( { shouldSetUpUSBankAccount : isIOUReport ( iouReport ) } ) ;
113110 } else if ( paymentMethod === CONST . PAYMENT_METHODS . DEBIT_CARD ) {
114111 Navigation . navigate ( addDebitCardRoute ?? ROUTES . HOME ) ;
115- } else if ( paymentMethod === CONST . PAYMENT_METHODS . BUSINESS_BANK_ACCOUNT || policy ) {
112+ } else if ( paymentMethod === CONST . PAYMENT_METHODS . BUSINESS_BANK_ACCOUNT ) {
116113 if ( iouReport && isIOUReport ( iouReport ) ) {
117- if ( policy ) {
118- const policyExpenseChatReportID = getPolicyExpenseChat ( iouReport . ownerAccountID , policy . id ) ?. reportID ;
119- if ( ! policyExpenseChatReportID ) {
120- const { policyExpenseChatReportID : newPolicyExpenseChatReportID } = moveIOUReportToPolicyAndInviteSubmitter ( iouReport . reportID , policy . id ) ?? { } ;
121- savePreferredPaymentMethod ( iouReport . policyID , policy . id , CONST . LAST_PAYMENT_METHOD . IOU ) ;
122- Navigation . navigate ( ROUTES . REPORT_WITH_ID . getRoute ( newPolicyExpenseChatReportID ) ) ;
123- } else {
124- moveIOUReportToPolicy ( iouReport . reportID , policy . id , true ) ;
125- savePreferredPaymentMethod ( iouReport . policyID , policy . id , CONST . LAST_PAYMENT_METHOD . IOU ) ;
126- Navigation . navigate ( ROUTES . REPORT_WITH_ID . getRoute ( policyExpenseChatReportID ) ) ;
127- }
128-
129- if ( policy ?. achAccount ) {
130- return ;
131- }
132- // Navigate to the bank account set up flow for this specific policy
133- Navigation . navigate ( ROUTES . BANK_ACCOUNT_WITH_STEP_TO_OPEN . getRoute ( policy . id ) ) ;
134- return ;
135- }
136-
137114 const { policyID, workspaceChatReportID, reportPreviewReportActionID, adminsChatReportID} = createWorkspaceFromIOUPayment ( iouReport ) ?? { } ;
138- if ( policyID ) {
139- savePreferredPaymentMethod ( iouReport . policyID , policyID , CONST . LAST_PAYMENT_METHOD . IOU ) ;
140- }
141115 completePaymentOnboarding ( CONST . PAYMENT_SELECTED . BBA , adminsChatReportID , policyID ) ;
142116 if ( workspaceChatReportID ) {
143117 Navigation . navigate ( ROUTES . REPORT_WITH_ID . getRoute ( workspaceChatReportID , reportPreviewReportActionID ) ) ;
144118 }
145119
146120 // Navigate to the bank account set up flow for this specific policy
147121 Navigation . navigate ( ROUTES . BANK_ACCOUNT_WITH_STEP_TO_OPEN . getRoute ( policyID ) ) ;
122+
148123 return ;
149124 }
150125 Navigation . navigate ( addBankAccountRoute ) ;
@@ -160,7 +135,7 @@ function KYCWall({
160135 *
161136 */
162137 const continueAction = useCallback (
163- ( event ?: GestureResponderEvent | KeyboardEvent , iouPaymentType ?: PaymentMethodType , paymentMethod ?: PaymentMethod , policy ?: Policy ) => {
138+ ( event ?: GestureResponderEvent | KeyboardEvent , iouPaymentType ?: PaymentMethodType ) => {
164139 const currentSource = walletTerms ?. source ?? source ;
165140
166141 /**
@@ -194,19 +169,6 @@ function KYCWall({
194169 return ;
195170 }
196171
197- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
198- if ( paymentMethod || policy ) {
199- setShouldShowAddPaymentMenu ( false ) ;
200- selectPaymentMethod ( paymentMethod , policy ) ;
201- return ;
202- }
203-
204- if ( iouPaymentType && isExpenseReport ) {
205- setShouldShowAddPaymentMenu ( false ) ;
206- selectPaymentMethod ( CONST . PAYMENT_METHODS . BUSINESS_BANK_ACCOUNT ) ;
207- return ;
208- }
209-
210172 const clickedElementLocation = getClickedTargetLocation ( targetElement as HTMLDivElement ) ;
211173 const position = getAnchorPosition ( clickedElementLocation ) ;
212174
@@ -219,20 +181,13 @@ function KYCWall({
219181 // Ask the user to upgrade to a gold wallet as this means they have not yet gone through our Know Your Customer (KYC) checks
220182 const hasActivatedWallet = userWallet ?. tierName && [ CONST . WALLET . TIER_NAME . GOLD , CONST . WALLET . TIER_NAME . PLATINUM ] . some ( ( name ) => name === userWallet . tierName ) ;
221183
222- if ( ! hasActivatedWallet && ! policy ) {
184+ if ( ! hasActivatedWallet ) {
223185 Log . info ( '[KYC Wallet] User does not have active wallet' ) ;
224186
225187 Navigation . navigate ( enablePaymentsRoute ) ;
226188
227189 return ;
228190 }
229-
230- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
231- if ( ( paymentMethod || policy ) && ! hasActivatedWallet ) {
232- setShouldShowAddPaymentMenu ( false ) ;
233- selectPaymentMethod ( paymentMethod , policy ) ;
234- return ;
235- }
236191 }
237192
238193 Log . info ( '[KYC Wallet] User has valid payment method and passed KYC checks or did not need them' ) ;
0 commit comments