Skip to content

Commit

Permalink
clean up logic
Browse files Browse the repository at this point in the history
  • Loading branch information
luacmartins committed Feb 22, 2023
1 parent e39513e commit 70f5212
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 70f5212

Please sign in to comment.