@@ -14,13 +14,15 @@ import UnreadActionIndicator from '@components/UnreadActionIndicator';
1414import useLocalize from '@hooks/useLocalize' ;
1515import useNetwork from '@hooks/useNetwork' ;
1616import useOnyx from '@hooks/useOnyx' ;
17+ import useReportTransactions from '@hooks/useReportTransactions' ;
1718import useStyleUtils from '@hooks/useStyleUtils' ;
1819import useTheme from '@hooks/useTheme' ;
1920import useThemeStyles from '@hooks/useThemeStyles' ;
2021import { convertToDisplayString } from '@libs/CurrencyUtils' ;
2122import { resolveReportFieldValue } from '@libs/Formula' ;
2223import Navigation from '@libs/Navigation/Navigation' ;
2324import {
25+ getBillableAndTaxTotal ,
2426 getFieldViolation ,
2527 getFieldViolationTranslation ,
2628 getMoneyRequestSpendBreakdown ,
@@ -36,9 +38,11 @@ import {
3638 isSettled as isSettledReportUtils ,
3739 shouldHideSingleReportField ,
3840} from '@libs/ReportUtils' ;
41+ import { getTransactionPendingAction } from '@libs/TransactionUtils' ;
3942import AnimatedEmptyStateBackground from '@pages/inbox/report/AnimatedEmptyStateBackground' ;
4043import variables from '@styles/variables' ;
4144import CONST from '@src/CONST' ;
45+ import type { TranslationPaths } from '@src/languages/types' ;
4246import { clearReportFieldKeyErrors } from '@src/libs/actions/Report' ;
4347import ONYXKEYS from '@src/ONYXKEYS' ;
4448import ROUTES from '@src/ROUTES' ;
@@ -74,11 +78,15 @@ function MoneyReportView({report, policy, isCombinedReport = false, shouldShowTo
7478 const isTotalUpdated = hasUpdatedTotal ( report , policy ) ;
7579
7680 const { totalDisplaySpend, nonReimbursableSpend, reimbursableSpend} = getMoneyRequestSpendBreakdown ( report ) ;
81+ const transactions = useReportTransactions ( report ?. reportID ) ;
82+ const { billableTotal, taxTotal} = getBillableAndTaxTotal ( report , transactions ) ;
7783
78- const shouldShowBreakdown = nonReimbursableSpend && reimbursableSpend && shouldShowTotal ;
84+ const shouldShowBreakdown = ( nonReimbursableSpend && reimbursableSpend ) || ! ! billableTotal || ! ! taxTotal ;
7985 const formattedTotalAmount = convertToDisplayString ( totalDisplaySpend , report ?. currency ) ;
8086 const formattedOutOfPocketAmount = convertToDisplayString ( reimbursableSpend , report ?. currency ) ;
8187 const formattedCompanySpendAmount = convertToDisplayString ( nonReimbursableSpend , report ?. currency ) ;
88+ const formattedBillableAmount = convertToDisplayString ( billableTotal , report ?. currency ) ;
89+ const formattedTaxAmount = convertToDisplayString ( taxTotal , report ?. currency ) ;
8290 const isPartiallyPaid = ! ! report ?. pendingFields ?. partial ;
8391
8492 const subAmountTextStyles : StyleProp < TextStyle > = [
@@ -112,6 +120,8 @@ function MoneyReportView({report, policy, isCombinedReport = false, shouldShowTo
112120 ( ! isCombinedReport || ! isOnlyTitleFieldEnabled ) &&
113121 ! sortedPolicyReportFields . every ( shouldHideSingleReportField ) ;
114122
123+ const hasPendingAction = transactions . some ( getTransactionPendingAction ) ;
124+
115125 const renderThreadDivider = useMemo (
116126 ( ) =>
117127 shouldHideThreadDividerLine ? (
@@ -218,42 +228,36 @@ function MoneyReportView({report, policy, isCombinedReport = false, shouldShowTo
218228
219229 { ! ! shouldShowBreakdown && (
220230 < >
221- < View style = { [ styles . flexRow , styles . pointerEventsNone , styles . containerWithSpaceBetween , styles . ph5 , styles . pv1 ] } >
222- < View style = { [ styles . flex1 , styles . justifyContentCenter ] } >
223- < Text
224- style = { [ styles . textLabelSupporting ] }
225- numberOfLines = { 1 }
226- >
227- { translate ( 'cardTransactions.outOfPocket' ) }
228- </ Text >
229- </ View >
230- < View style = { [ styles . flexRow , styles . justifyContentCenter ] } >
231- < Text
232- numberOfLines = { 1 }
233- style = { subAmountTextStyles }
231+ { [
232+ { label : 'cardTransactions.outOfPocket' , value : formattedOutOfPocketAmount , show : ! ! nonReimbursableSpend && ! ! reimbursableSpend } ,
233+ { label : 'cardTransactions.companySpend' , value : formattedCompanySpendAmount , show : ! ! nonReimbursableSpend && ! ! reimbursableSpend } ,
234+ { label : 'common.billable' , value : formattedBillableAmount , show : ! ! billableTotal } ,
235+ { label : 'common.tax' , value : formattedTaxAmount , show : ! ! taxTotal } ,
236+ ]
237+ . filter ( ( { show} ) => show )
238+ . map ( ( { label, value} ) => (
239+ < View
240+ key = { label }
241+ style = { [ styles . flexRow , styles . pointerEventsNone , styles . containerWithSpaceBetween , styles . ph5 , styles . pv1 ] }
234242 >
235- { formattedOutOfPocketAmount }
236- </ Text >
237- </ View >
238- </ View >
239- < View style = { [ styles . flexRow , styles . pointerEventsNone , styles . containerWithSpaceBetween , styles . ph5 , styles . pv1 ] } >
240- < View style = { [ styles . flex1 , styles . justifyContentCenter ] } >
241- < Text
242- style = { [ styles . textLabelSupporting ] }
243- numberOfLines = { 1 }
244- >
245- { translate ( 'cardTransactions.companySpend' ) }
246- </ Text >
247- </ View >
248- < View style = { [ styles . flexRow , styles . justifyContentCenter ] } >
249- < Text
250- numberOfLines = { 1 }
251- style = { subAmountTextStyles }
252- >
253- { formattedCompanySpendAmount }
254- </ Text >
255- </ View >
256- </ View >
243+ < View style = { [ styles . flex1 , styles . justifyContentCenter ] } >
244+ < Text
245+ style = { [ styles . textLabelSupporting , hasPendingAction && styles . opacitySemiTransparent ] }
246+ numberOfLines = { 1 }
247+ >
248+ { translate ( label as TranslationPaths ) }
249+ </ Text >
250+ </ View >
251+ < View style = { [ styles . flexRow , styles . justifyContentCenter ] } >
252+ < Text
253+ numberOfLines = { 1 }
254+ style = { [ subAmountTextStyles , hasPendingAction && styles . opacitySemiTransparent ] }
255+ >
256+ { value }
257+ </ Text >
258+ </ View >
259+ </ View >
260+ ) ) }
257261 </ >
258262 ) }
259263 </ >
0 commit comments