Skip to content

Commit

Permalink
Account for both options and reports in unread check
Browse files Browse the repository at this point in the history
  • Loading branch information
puneetlath committed Oct 31, 2023
1 parent b35d1da commit efcefdb
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,21 @@ function isWaitingForAssigneeToCompleteTask(report, parentReportAction = {}) {
return isTaskReport(report) && isReportManager(report) && isOpenTaskReport(report, parentReportAction);
}

/**
* @param {Object} report
* @returns {Boolean}
*/
function isUnreadWithMention(report) {
if (!report) {
return false;
}

// lastMentionedTime and lastReadTime are both datetime strings and can be compared directly
const lastMentionedTime = report.lastMentionedTime || '';
const lastReadTime = report.lastReadTime || '';
return lastReadTime < lastMentionedTime;
}

/**
* Determines if the option requires action from the current user. This can happen when it:
- is unread and the user was mentioned in one of the unread comments
Expand All @@ -1353,7 +1368,7 @@ function requiresAttentionFromCurrentUser(option, parentReportAction = {}) {
return false;
}

if (option.isUnreadWithMention) {
if (option.isUnreadWithMention || isUnreadWithMention(option)) {
return true;
}

Expand Down Expand Up @@ -3105,21 +3120,6 @@ function isUnread(report) {
return lastReadTime < lastVisibleActionCreated;
}

/**
* @param {Object} report
* @returns {Boolean}
*/
function isUnreadWithMention(report) {
if (!report) {
return false;
}

// lastMentionedTime and lastReadTime are both datetime strings and can be compared directly
const lastMentionedTime = report.lastMentionedTime || '';
const lastReadTime = report.lastReadTime || '';
return lastReadTime < lastMentionedTime;
}

/**
* @param {Object} report
* @param {Object} allReportsDict
Expand Down

0 comments on commit efcefdb

Please sign in to comment.