From f71e72baa3f532eda8f7ef206c2c2684e455eb92 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 24 Jun 2024 10:06:53 +0700 Subject: [PATCH 1/3] fix: Total amount for the report in Shared is -0.00 --- src/components/SelectionList/Search/ReportListItem.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx index 313794eb2064..200c5d6b551b 100644 --- a/src/components/SelectionList/Search/ReportListItem.tsx +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -35,11 +35,17 @@ type ActionCellProps = { function TotalCell({showTooltip, isLargeScreenWidth, reportItem}: ReportCellProps) { const styles = useThemeStyles(); + + let total = reportItem?.total ?? 0; + + if (total) { + total *= (reportItem?.type === CONST.REPORT.TYPE.EXPENSE ? -1 : 1); + } return ( ); @@ -77,7 +83,7 @@ function ReportListItem({ const {translate} = useLocalize(); const {isLargeScreenWidth} = useWindowDimensions(); const StyleUtils = useStyleUtils(); - + if (reportItem.transactions.length === 0) { return; } From 2b032fcdf4d9b31b025322a03d55621249df86a2 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 24 Jun 2024 10:21:33 +0700 Subject: [PATCH 2/3] fix lint --- src/components/SelectionList/Search/ReportListItem.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx index 200c5d6b551b..c6a6e321bfb0 100644 --- a/src/components/SelectionList/Search/ReportListItem.tsx +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -35,11 +35,11 @@ type ActionCellProps = { function TotalCell({showTooltip, isLargeScreenWidth, reportItem}: ReportCellProps) { const styles = useThemeStyles(); - + let total = reportItem?.total ?? 0; if (total) { - total *= (reportItem?.type === CONST.REPORT.TYPE.EXPENSE ? -1 : 1); + total *= reportItem?.type === CONST.REPORT.TYPE.EXPENSE ? -1 : 1; } return ( @@ -83,7 +83,7 @@ function ReportListItem({ const {translate} = useLocalize(); const {isLargeScreenWidth} = useWindowDimensions(); const StyleUtils = useStyleUtils(); - + if (reportItem.transactions.length === 0) { return; } From fe3bb0b148414a1f6ac142af105d4c3bd729c62b Mon Sep 17 00:00:00 2001 From: nkdengineer <161821005+nkdengineer@users.noreply.github.com> Date: Tue, 25 Jun 2024 11:04:32 +0700 Subject: [PATCH 3/3] Update src/components/SelectionList/Search/ReportListItem.tsx Co-authored-by: Andrew Rosiclair --- src/components/SelectionList/Search/ReportListItem.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx index c6a6e321bfb0..6aad36821187 100644 --- a/src/components/SelectionList/Search/ReportListItem.tsx +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -38,6 +38,7 @@ function TotalCell({showTooltip, isLargeScreenWidth, reportItem}: ReportCellProp let total = reportItem?.total ?? 0; + // Only invert non-zero values otherwise we'll end up with -0.00 if (total) { total *= reportItem?.type === CONST.REPORT.TYPE.EXPENSE ? -1 : 1; }