Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {Fragment, useMemo} from 'react';
import React, {Fragment} from 'react';
import {View} from 'react-native';
import type {StyleProp, ViewStyle} from 'react-native';
import Checkbox from '@components/Checkbox';
Expand All @@ -13,6 +13,7 @@ import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import getBase62ReportID from '@libs/getBase62ReportID';
import {getMoneyRequestSpendBreakdown} from '@libs/ReportUtils';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import type {Policy} from '@src/types/onyx';
Expand Down Expand Up @@ -64,24 +65,8 @@ function ExpenseReportListItemRow({
const {isLargeScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout();
const expensifyIcons = useMemoizedLazyExpensifyIcons(['ArrowRight']);

const {total, currency} = useMemo(() => {
let reportTotal = item.total ?? 0;

if (reportTotal) {
if (item.type === CONST.REPORT.TYPE.IOU) {
reportTotal = Math.abs(reportTotal ?? 0);
} else {
reportTotal *= item.type === CONST.REPORT.TYPE.EXPENSE || item.type === CONST.REPORT.TYPE.INVOICE ? -1 : 1;
}
}

const reportCurrency = item.currency ?? CONST.CURRENCY.USD;

return {total: reportTotal, currency: reportCurrency};
}, [item.type, item.total, item.currency]);

const nonReimbursableTotal = item.nonReimbursableTotal ?? 0;
const reimbursableTotal = total - nonReimbursableTotal;
const currency = item.currency ?? CONST.CURRENCY.USD;
const {totalDisplaySpend, nonReimbursableSpend, reimbursableSpend} = getMoneyRequestSpendBreakdown(item);

const columnComponents = {
[CONST.SEARCH.TABLE_COLUMNS.DATE]: (
Expand Down Expand Up @@ -161,23 +146,23 @@ function ExpenseReportListItemRow({
[CONST.SEARCH.TABLE_COLUMNS.REIMBURSABLE_TOTAL]: (
<View style={[StyleUtils.getReportTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.TOTAL)]}>
<TotalCell
total={reimbursableTotal}
total={reimbursableSpend}
currency={currency}
/>
</View>
),
[CONST.SEARCH.TABLE_COLUMNS.NON_REIMBURSABLE_TOTAL]: (
<View style={[StyleUtils.getReportTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.TOTAL)]}>
<TotalCell
total={nonReimbursableTotal}
total={nonReimbursableSpend}
currency={currency}
/>
</View>
),
[CONST.SEARCH.TABLE_COLUMNS.TOTAL]: (
<View style={[StyleUtils.getReportTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.TOTAL)]}>
<TotalCell
total={total}
total={totalDisplaySpend}
currency={currency}
/>
</View>
Expand Down Expand Up @@ -259,7 +244,7 @@ function ExpenseReportListItemRow({
</View>
<View style={[styles.flexShrink0, styles.flexColumn, styles.alignItemsEnd, styles.gap1]}>
<TotalCell
total={total}
total={totalDisplaySpend}
currency={currency}
/>
</View>
Expand Down
Loading