@@ -113,10 +113,15 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
113
113
const isArchivedReport = ReportUtils . isArchivedRoomWithID ( moneyRequestReport ?. reportID ) ;
114
114
const [ archiveReason ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ moneyRequestReport ?. reportID ?? '-1' } ` , { selector : ReportUtils . getArchiveReason } ) ;
115
115
116
- const shouldShowPayButton = useMemo (
117
- ( ) => IOU . canIOUBePaid ( moneyRequestReport , chatReport , policy , transaction ? [ transaction ] : undefined ) ,
116
+ const getCanIOUBePaid = useCallback (
117
+ ( onlyShowPayElsewhere = false ) => IOU . canIOUBePaid ( moneyRequestReport , chatReport , policy , transaction ? [ transaction ] : undefined , onlyShowPayElsewhere ) ,
118
118
[ moneyRequestReport , chatReport , policy , transaction ] ,
119
119
) ;
120
+ const canIOUBePaid = useMemo ( ( ) => getCanIOUBePaid ( ) , [ getCanIOUBePaid ] ) ;
121
+
122
+ const onlyShowPayElsewhere = useMemo ( ( ) => ! canIOUBePaid && getCanIOUBePaid ( true ) , [ canIOUBePaid , getCanIOUBePaid ] ) ;
123
+
124
+ const shouldShowPayButton = canIOUBePaid || onlyShowPayElsewhere ;
120
125
121
126
const shouldShowApproveButton = useMemo ( ( ) => IOU . canApproveIOU ( moneyRequestReport , policy ) , [ moneyRequestReport , policy ] ) ;
122
127
@@ -292,6 +297,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
292
297
{ shouldShowSettlementButton && ! shouldUseNarrowLayout && (
293
298
< View style = { styles . pv2 } >
294
299
< SettlementButton
300
+ onlyShowPayElsewhere = { onlyShowPayElsewhere }
295
301
currency = { moneyRequestReport ?. currency }
296
302
confirmApproval = { confirmApproval }
297
303
policyID = { moneyRequestReport ?. policyID }
@@ -345,6 +351,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
345
351
< View style = { [ styles . dFlex , styles . flexColumn , styles . gap3 , styles . pb3 , styles . ph5 , styles . borderBottom ] } >
346
352
{ shouldShowSettlementButton && shouldUseNarrowLayout && (
347
353
< SettlementButton
354
+ onlyShowPayElsewhere = { onlyShowPayElsewhere }
348
355
currency = { moneyRequestReport ?. currency }
349
356
confirmApproval = { confirmApproval }
350
357
policyID = { moneyRequestReport ?. policyID }
0 commit comments