Skip to content

Commit

Permalink
update logic to get money request total
Browse files Browse the repository at this point in the history
  • Loading branch information
mollfpr committed May 12, 2023
1 parent a1f6a83 commit 572bff6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -862,17 +862,15 @@ function getDisplayNamesWithTooltips(participants, isMultipleParticipantReport)
* @returns {Number}
*/
function getMoneyRequestTotal(report, moneyRequestReports = {}) {
if (report.hasOutstandingIOU) {
const moneyRequestReport = moneyRequestReports[`${ONYXKEYS.COLLECTION.REPORT}${report.iouReportID}`];
if (moneyRequestReport) {
return moneyRequestReport.total;
}
if (report.hasOutstandingIOU || isMoneyRequestReport(report)) {
const moneyRequestReport = moneyRequestReports[`${ONYXKEYS.COLLECTION.REPORT}${report.iouReportID}`] || report;
const total = lodashGet(moneyRequestReport, 'total', 0);

if (isMoneyRequestReport(report) && report.total !== 0) {
if (total !== 0) {
// There is a possibility that if the Expense report has a negative total.
// This is because there are instances where you can get a credit back on your card,
// or you enter a negative expense to “offset” future expenses
return isExpenseReport(report) ? report.total * -1 : Math.abs(report.total);
return isExpenseReport(moneyRequestReport) ? total * -1 : Math.abs(total);
}
}
return 0;
Expand Down

0 comments on commit 572bff6

Please sign in to comment.