@@ -17,8 +17,7 @@ import useTheme from '@hooks/useTheme';
1717import useThemeStyles from '@hooks/useThemeStyles' ;
1818import { turnOffMobileSelectionMode } from '@libs/actions/MobileSelectionMode' ;
1919import { downloadReportPDF , exportReportToCSV , exportReportToPDF , exportToIntegration , markAsManuallyExported , openUnreportedExpense } from '@libs/actions/Report' ;
20- import { convertToDisplayString } from '@libs/CurrencyUtils' ;
21- import { getThreadReportIDsForTransactions } from '@libs/MoneyRequestReportUtils' ;
20+ import { getThreadReportIDsForTransactions , getTotalAmountForIOUReportPreviewButton } from '@libs/MoneyRequestReportUtils' ;
2221import Navigation from '@libs/Navigation/Navigation' ;
2322import { buildOptimisticNextStepForPreventSelfApprovalsEnabled } from '@libs/NextStepUtils' ;
2423import { getConnectedIntegration } from '@libs/PolicyUtils' ;
@@ -31,7 +30,6 @@ import {
3130 getBankAccountRoute ,
3231 getIntegrationIcon ,
3332 getIntegrationNameFromExportMessage as getIntegrationNameFromExportMessageUtils ,
34- getMoneyRequestSpendBreakdown ,
3533 getNonHeldAndFullAmount ,
3634 getTransactionsWithReceipts ,
3735 hasHeldExpenses as hasHeldExpensesReportUtils ,
@@ -179,7 +177,6 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
179177 const theme = useTheme ( ) ;
180178 const { translate} = useLocalize ( ) ;
181179 const { isOffline} = useNetwork ( ) ;
182- const { reimbursableSpend} = getMoneyRequestSpendBreakdown ( moneyRequestReport ) ;
183180 const isOnHold = isOnHoldTransactionUtils ( transaction ) ;
184181
185182 const [ isHoldMenuVisible , setIsHoldMenuVisible ] = useState ( false ) ;
@@ -285,10 +282,8 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
285282
286283 const shouldShowNextStep = isFromPaidPolicy && ! ! optimisticNextStep ?. message ?. length && ! shouldShowStatusBar ;
287284 const bankAccountRoute = getBankAccountRoute ( chatReport ) ;
288- const formattedAmount = convertToDisplayString ( reimbursableSpend , moneyRequestReport ?. currency ) ;
289285 const { nonHeldAmount, fullAmount, hasValidNonHeldAmount} = getNonHeldAndFullAmount ( moneyRequestReport , shouldShowPayButton ) ;
290286 const isAnyTransactionOnHold = hasHeldExpensesReportUtils ( moneyRequestReport ?. reportID ) ;
291- const displayedAmount = isAnyTransactionOnHold && canAllowSettlement && hasValidNonHeldAmount ? nonHeldAmount : formattedAmount ;
292287 const { isDelegateAccessRestricted} = useDelegateUserDetails ( ) ;
293288 const [ isNoDelegateAccessMenuVisible , setIsNoDelegateAccessMenuVisible ] = useState ( false ) ;
294289 const [ isLoadingReportData ] = useOnyx ( ONYXKEYS . IS_LOADING_REPORT_DATA , { canBeMissing : true } ) ;
@@ -460,6 +455,10 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
460455 [ moneyRequestReport ?. reportID , translate ] ,
461456 ) ;
462457
458+ const getAmount = ( actionType : ValueOf < typeof CONST . REPORT . REPORT_PREVIEW_ACTIONS > ) => ( {
459+ formattedAmount : getTotalAmountForIOUReportPreviewButton ( moneyRequestReport , policy , actionType ) ,
460+ } ) ;
461+
463462 const primaryActionsImplementation = {
464463 [ CONST . REPORT . PRIMARY_ACTIONS . SUBMIT ] : (
465464 < Button
@@ -477,7 +476,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
477476 < Button
478477 success
479478 onPress = { confirmApproval }
480- text = { translate ( 'iou.approve' ) }
479+ text = { translate ( 'iou.approve' , getAmount ( CONST . REPORT . PRIMARY_ACTIONS . APPROVE ) ) }
481480 />
482481 ) ,
483482 [ CONST . REPORT . PRIMARY_ACTIONS . PAY ] : (
@@ -498,7 +497,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
498497 shouldHidePaymentOptions = { ! shouldShowPayButton }
499498 shouldShowApproveButton = { shouldShowApproveButton }
500499 shouldDisableApproveButton = { shouldDisableApproveButton }
501- formattedAmount = { ! hasOnlyHeldExpenses ? displayedAmount : '' }
500+ formattedAmount = { getAmount ( CONST . REPORT . PRIMARY_ACTIONS . PAY ) . formattedAmount }
502501 isDisabled = { isOffline && ! canAllowSettlement }
503502 isLoading = { ! isOffline && ! canAllowSettlement }
504503 />
@@ -626,7 +625,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
626625 } ,
627626 } ,
628627 [ CONST . REPORT . SECONDARY_ACTIONS . APPROVE ] : {
629- text : translate ( 'iou.approve' ) ,
628+ text : translate ( 'iou.approve' , getAmount ( CONST . REPORT . SECONDARY_ACTIONS . APPROVE ) ) ,
630629 icon : Expensicons . ThumbsUp ,
631630 value : CONST . REPORT . SECONDARY_ACTIONS . APPROVE ,
632631 onSelected : ( ) => {
0 commit comments