@@ -183,73 +183,76 @@ function SettlementButton({
183183 return formattedPaymentMethods . filter ( ( ba ) => ( ba . accountData as AccountData ) ?. type === CONST . BANK_ACCOUNT . TYPE . PERSONAL ) ;
184184 }
185185
186- const checkForNecessaryAction = useCallback ( ( ) => {
187- if ( isDelegateAccessRestricted ) {
188- showDelegateNoAccessModal ( ) ;
189- return true ;
190- }
186+ const checkForNecessaryAction = useCallback (
187+ ( paymentMethodType ?: PaymentMethodType ) => {
188+ if ( isDelegateAccessRestricted ) {
189+ showDelegateNoAccessModal ( ) ;
190+ return true ;
191+ }
191192
192- if ( isAccountLocked ) {
193- showLockedAccountModal ( ) ;
194- return true ;
195- }
193+ if ( isAccountLocked ) {
194+ showLockedAccountModal ( ) ;
195+ return true ;
196+ }
196197
197- if ( ! isUserValidated ) {
198- handleUnvalidatedUserNavigation ( chatReportID , reportID ) ;
199- return true ;
200- }
198+ if ( ! isUserValidated && paymentMethodType !== CONST . IOU . PAYMENT_TYPE . ELSEWHERE ) {
199+ handleUnvalidatedUserNavigation ( chatReportID , reportID ) ;
200+ return true ;
201+ }
201202
202- if ( isBankAccountLocked ) {
203- showConfirmModal ( {
204- title : translate ( 'bankAccount.lockedBankAccount' ) ,
205- prompt : (
206- < View style = { [ styles . renderHTML , styles . flexRow ] } >
207- < RenderHTML html = { translate ( 'bankAccount.youCantPayThis' ) } />
208- </ View >
209- ) ,
210- confirmText : translate ( 'bankAccount.unlockBankAccount' ) ,
211- cancelText : translate ( 'common.cancel' ) ,
212- } ) . then ( ( { action} ) => {
213- if ( action !== ModalActions . CONFIRM ) {
214- return ;
215- }
216- if ( policy ?. achAccount ?. bankAccountID === undefined ) {
217- return ;
218- }
219- pressLockedBankAccount ( policy ?. achAccount ?. bankAccountID , translate , conciergeReportID ) ;
220- navigateToConciergeChat ( conciergeReportID , introSelected , currentUserAccountID , isSelfTourViewed , betas ) ;
221- } ) ;
222- return true ;
223- }
203+ if ( isBankAccountLocked ) {
204+ showConfirmModal ( {
205+ title : translate ( 'bankAccount.lockedBankAccount' ) ,
206+ prompt : (
207+ < View style = { [ styles . renderHTML , styles . flexRow ] } >
208+ < RenderHTML html = { translate ( 'bankAccount.youCantPayThis' ) } />
209+ </ View >
210+ ) ,
211+ confirmText : translate ( 'bankAccount.unlockBankAccount' ) ,
212+ cancelText : translate ( 'common.cancel' ) ,
213+ } ) . then ( ( { action} ) => {
214+ if ( action !== ModalActions . CONFIRM ) {
215+ return ;
216+ }
217+ if ( policy ?. achAccount ?. bankAccountID === undefined ) {
218+ return ;
219+ }
220+ pressLockedBankAccount ( policy ?. achAccount ?. bankAccountID , translate , conciergeReportID ) ;
221+ navigateToConciergeChat ( conciergeReportID , introSelected , currentUserAccountID , isSelfTourViewed , betas ) ;
222+ } ) ;
223+ return true ;
224+ }
224225
225- if ( policy && shouldRestrictUserBillableActions ( policy . id , ownerBillingGraceEndPeriod , userBillingGraceEndPeriods ) ) {
226- Navigation . navigate ( ROUTES . RESTRICTED_ACTION . getRoute ( policy . id ) ) ;
227- return true ;
228- }
226+ if ( policy && shouldRestrictUserBillableActions ( policy . id , ownerBillingGraceEndPeriod , userBillingGraceEndPeriods ) ) {
227+ Navigation . navigate ( ROUTES . RESTRICTED_ACTION . getRoute ( policy . id ) ) ;
228+ return true ;
229+ }
229230
230- return false ;
231- } , [
232- isDelegateAccessRestricted ,
233- isAccountLocked ,
234- isUserValidated ,
235- isBankAccountLocked ,
236- policy ,
237- userBillingGraceEndPeriods ,
238- ownerBillingGraceEndPeriod ,
239- showDelegateNoAccessModal ,
240- showLockedAccountModal ,
241- chatReportID ,
242- reportID ,
243- showConfirmModal ,
244- translate ,
245- styles . renderHTML ,
246- styles . flexRow ,
247- conciergeReportID ,
248- introSelected ,
249- currentUserAccountID ,
250- isSelfTourViewed ,
251- betas ,
252- ] ) ;
231+ return false ;
232+ } ,
233+ [
234+ isDelegateAccessRestricted ,
235+ isAccountLocked ,
236+ isUserValidated ,
237+ isBankAccountLocked ,
238+ policy ,
239+ userBillingGraceEndPeriods ,
240+ ownerBillingGraceEndPeriod ,
241+ showDelegateNoAccessModal ,
242+ showLockedAccountModal ,
243+ chatReportID ,
244+ reportID ,
245+ showConfirmModal ,
246+ translate ,
247+ styles . renderHTML ,
248+ styles . flexRow ,
249+ conciergeReportID ,
250+ introSelected ,
251+ currentUserAccountID ,
252+ isSelfTourViewed ,
253+ betas ,
254+ ] ,
255+ ) ;
253256
254257 const shortFormPayElsewhereButton = {
255258 text : translate ( 'iou.pay' ) ,
@@ -320,7 +323,7 @@ function SettlementButton({
320323 value : CONST . PAYMENT_METHODS . BUSINESS_BANK_ACCOUNT ,
321324 description : account . description ,
322325 onSelected : ( ) => {
323- if ( checkForNecessaryAction ( ) ) {
326+ if ( checkForNecessaryAction ( CONST . IOU . PAYMENT_TYPE . VBBA ) ) {
324327 return ;
325328 }
326329 onPress ( {
@@ -383,7 +386,7 @@ function SettlementButton({
383386 icon : formattedPaymentMethod ?. icon ,
384387 shouldUpdateSelectedIndex : true ,
385388 onSelected : ( ) => {
386- if ( checkForNecessaryAction ( ) ) {
389+ if ( checkForNecessaryAction ( CONST . IOU . PAYMENT_TYPE . EXPENSIFY ) ) {
387390 return ;
388391 }
389392 onPress ( {
@@ -442,7 +445,7 @@ function SettlementButton({
442445 value : CONST . IOU . PAYMENT_TYPE . ELSEWHERE ,
443446 shouldUpdateSelectedIndex : true ,
444447 onSelected : ( ) => {
445- if ( checkForNecessaryAction ( ) ) {
448+ if ( checkForNecessaryAction ( CONST . IOU . PAYMENT_TYPE . ELSEWHERE ) ) {
446449 return ;
447450 }
448451 onPress ( { paymentType : CONST . IOU . PAYMENT_TYPE . ELSEWHERE , payAsBusiness} ) ;
@@ -551,16 +554,16 @@ function SettlementButton({
551554 } ;
552555
553556 const handlePaymentSelection = ( event : GestureResponderEvent | KeyboardEvent | undefined , selectedOption : string , triggerKYCFlow : ( params : ContinueActionParams ) => void ) => {
554- if ( checkForNecessaryAction ( ) ) {
555- return ;
556- }
557-
558557 const { paymentType, policyFromPaymentMethod, policyFromContext, shouldSelectPaymentMethod} = getActivePaymentType (
559558 selectedOption ,
560559 activeAdminPolicies ,
561560 businessBankAccountOptions ,
562561 policyIDKey ,
563562 ) ;
563+
564+ if ( checkForNecessaryAction ( paymentType ) ) {
565+ return ;
566+ }
564567 const isPayingWithMethod = paymentType !== CONST . IOU . PAYMENT_TYPE . ELSEWHERE ;
565568
566569 if ( ( ! ! policyFromPaymentMethod || shouldSelectPaymentMethod ) && ( isPayingWithMethod || ! ! policyFromPaymentMethod ) ) {
0 commit comments