Skip to content

Commit

Permalink
Merge pull request #36276 from Expensify/rodrigo-fix-unread-deleted-m…
Browse files Browse the repository at this point in the history
…ention

Using lastMentionedTime to check if chat is unread
  • Loading branch information
pecanoro authored Feb 12, 2024
2 parents 59559c4 + b4811d2 commit 5f483a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3634,7 +3634,10 @@ function isUnread(report: OnyxEntry<Report>): boolean {
// lastVisibleActionCreated and lastReadTime are both datetime strings and can be compared directly
const lastVisibleActionCreated = report.lastVisibleActionCreated ?? '';
const lastReadTime = report.lastReadTime ?? '';
return lastReadTime < lastVisibleActionCreated;
const lastMentionedTime = report.lastMentionedTime ?? '';

// If the user was mentioned and the comment got deleted the lastMentionedTime will be more recent than the lastVisibleActionCreated
return lastReadTime < lastVisibleActionCreated || lastReadTime < lastMentionedTime;
}

function isIOUOwnedByCurrentUser(report: OnyxEntry<Report>, allReportsDict: OnyxCollection<Report> = null): boolean {
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ function ReportScreen({
oldPolicyName: reportProp.oldPolicyName,
policyName: reportProp.policyName,
isOptimisticReport: reportProp.isOptimisticReport,
lastMentionedTime: reportProp.lastMentionedTime,
}),
[
reportProp.lastReadTime,
Expand Down Expand Up @@ -242,6 +243,7 @@ function ReportScreen({
reportProp.oldPolicyName,
reportProp.policyName,
reportProp.isOptimisticReport,
reportProp.lastMentionedTime,
],
);

Expand Down

0 comments on commit 5f483a4

Please sign in to comment.