From b4811d29bdf1c04191867f69e13419939ba614da Mon Sep 17 00:00:00 2001 From: Rodrigo Lino da Costa Date: Fri, 9 Feb 2024 15:16:44 -0300 Subject: [PATCH] using lastMentionedTime to check if chat is unread --- src/libs/ReportUtils.ts | 5 ++++- src/pages/home/ReportScreen.js | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 3bf909bf14d5..26330d17db39 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3578,7 +3578,10 @@ function isUnread(report: OnyxEntry): 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, allReportsDict: OnyxCollection = null): boolean { diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 8a6d7045dc5f..4ac60bec4571 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -206,6 +206,7 @@ function ReportScreen({ oldPolicyName: reportProp.oldPolicyName, policyName: reportProp.policyName, isOptimisticReport: reportProp.isOptimisticReport, + lastMentionedTime: reportProp.lastMentionedTime, }), [ reportProp.lastReadTime, @@ -242,6 +243,7 @@ function ReportScreen({ reportProp.oldPolicyName, reportProp.policyName, reportProp.isOptimisticReport, + reportProp.lastMentionedTime, ], );