From 70f5212c92185118e5ff9977e1c4dc856f5b4e06 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 21 Feb 2023 20:00:01 -0700 Subject: [PATCH] clean up logic --- src/libs/OptionsListUtils.js | 2 +- src/libs/ReportUtils.js | 5 ++--- src/libs/SidebarUtils.js | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 0f8c3828a543..9ba30883a9f0 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -361,7 +361,7 @@ function createOption(logins, personalDetails, report, reportActions = {}, { result.alternateText = Str.removeSMSDomain(personalDetail.login); } - result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result, currentUserLogin, iouReports); + result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result, iouReports); result.iouReportAmount = ReportUtils.getIOUTotal(result, iouReports); if (!hasMultipleParticipants) { diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 4c0a3f9d2523..3b2b55883343 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1257,15 +1257,14 @@ function getIOUTotal(report, iouReports = {}) { /** * @param {Object} report * @param {String} report.iouReportID - * @param {Object} currentUserLogin * @param {Object} iouReports * @returns {Boolean} */ -function isIOUOwnedByCurrentUser(report, currentUserLogin, iouReports = {}) { +function isIOUOwnedByCurrentUser(report, iouReports = {}) { if (report.hasOutstandingIOU) { const iouReport = iouReports[`${ONYXKEYS.COLLECTION.REPORT}${report.iouReportID}`]; if (iouReport) { - return iouReport.ownerEmail === currentUserLogin.email; + return iouReport.ownerEmail === currentUserEmail; } } return false; diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js index 5e3f412f162a..5cf2514efcd8 100644 --- a/src/libs/SidebarUtils.js +++ b/src/libs/SidebarUtils.js @@ -129,7 +129,7 @@ function getOrderedReportIDs(reportIDFromRoute) { return; } - if (report.hasOutstandingIOU && !ReportUtils.isIOUOwnedByCurrentUser(report, currentUserLogin, iouReports)) { + if (report.hasOutstandingIOU && !ReportUtils.isIOUOwnedByCurrentUser(report, iouReports)) { outstandingIOUReports.push(report); return; } @@ -283,7 +283,7 @@ function getOptionData(reportID) { result.alternateText = lastMessageText || Str.removeSMSDomain(personalDetail.login); } - result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result, currentUserLogin, iouReports); + result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result, iouReports); result.iouReportAmount = ReportUtils.getIOUTotal(result, iouReports); if (!hasMultipleParticipants) {