From de66dc5f628e272b977cff86766c8137d2274463 Mon Sep 17 00:00:00 2001 From: I Nyoman Jyotisa Date: Fri, 11 Jul 2025 14:49:07 +0800 Subject: [PATCH 1/4] Fix: New message marker is not displayed on the first message in expense report --- .../MoneyRequestReportActionsList.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx index 421ed2abf5c5..1880fee45c33 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx @@ -287,9 +287,15 @@ function MoneyRequestReportActionsList({ lastMessageTime.current = null; const hasNewMessagesInView = scrollingVerticalBottomOffset.current < CONST.REPORT.ACTIONS.ACTION_VISIBLE_THRESHOLD; - const hasUnreadReportAction = reportActions.some( - (reportAction) => newMessageTimeReference && newMessageTimeReference < reportAction.created && reportAction.actorAccountID !== getCurrentUserAccountID(), - ); + const hasUnreadReportAction = reportActions.some((reportAction) => { + if (!newMessageTimeReference || newMessageTimeReference >= reportAction.created) { + return false; + } + // Include system messages (non-comment actions) even if they're from the current user + const isSystemMessage = reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT; + + return isSystemMessage || reportAction.actorAccountID !== getCurrentUserAccountID(); + }); if (!hasNewMessagesInView || !hasUnreadReportAction) { return; @@ -329,7 +335,7 @@ function MoneyRequestReportActionsList({ // Scan through each visible report action until we find the appropriate action to show the unread marker for (let index = startIndex; index >= endIndex; index--) { const reportAction = visibleReportActions.at(index); - const nextAction = visibleReportActions.at(index - 1); + const nextAction = index > 0 ? visibleReportActions.at(index - 1) : undefined; const isEarliestReceivedOfflineMessage = index === earliestReceivedOfflineMessageIndex; const shouldDisplayNewMarker = From 4252c2a3d3d3e79339ace2817411a6d920473eaf Mon Sep 17 00:00:00 2001 From: I Nyoman Jyotisa Date: Thu, 17 Jul 2025 13:53:18 +0800 Subject: [PATCH 2/4] Fix: New message marker is not displayed on the first message in expense report --- .../MoneyRequestReportActionsList.tsx | 16 ++++++---------- src/pages/home/report/ReportActionsList.tsx | 5 +++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx index 1880fee45c33..a8c4e5ed9068 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx @@ -41,6 +41,7 @@ import { isCurrentActionUnread, isDeletedParentAction, isIOUActionMatchingTransactionList, + isReportActionUnread, shouldReportActionBeVisible, wasMessageReceivedWhileOffline, } from '@libs/ReportActionsUtils'; @@ -256,7 +257,8 @@ function MoneyRequestReportActionsList({ }, []); useEffect(() => { - if (isUnread(report, transactionThreadReport) || (lastAction && isCurrentActionUnread(report, lastAction))) { + const hasAnyUnreadActions = reportActions.some((action) => isReportActionUnread(action, report?.lastReadTime ?? '')); + if (isUnread(report, transactionThreadReport) || (lastAction && isCurrentActionUnread(report, lastAction)) || hasAnyUnreadActions) { // On desktop, when the notification center is displayed, isVisible will return false. // Currently, there's no programmatic way to dismiss the notification center panel. // To handle this, we use the 'referrer' parameter to check if the current navigation is triggered from a notification. @@ -287,15 +289,9 @@ function MoneyRequestReportActionsList({ lastMessageTime.current = null; const hasNewMessagesInView = scrollingVerticalBottomOffset.current < CONST.REPORT.ACTIONS.ACTION_VISIBLE_THRESHOLD; - const hasUnreadReportAction = reportActions.some((reportAction) => { - if (!newMessageTimeReference || newMessageTimeReference >= reportAction.created) { - return false; - } - // Include system messages (non-comment actions) even if they're from the current user - const isSystemMessage = reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT; - - return isSystemMessage || reportAction.actorAccountID !== getCurrentUserAccountID(); - }); + const hasUnreadReportAction = reportActions.some( + (reportAction) => newMessageTimeReference && newMessageTimeReference < reportAction.created && reportAction.actorAccountID !== getCurrentUserAccountID(), + ); if (!hasNewMessagesInView || !hasUnreadReportAction) { return; diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index 359c5801d3a9..fc58f90d6d5f 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -32,6 +32,7 @@ import { isConsecutiveChronosAutomaticTimerAction, isCurrentActionUnread, isDeletedParentAction, + isReportActionUnread, isReportPreviewAction, isReversedTransaction, isTransactionThread, @@ -366,8 +367,8 @@ function ReportActionsList({ if (report.reportID !== prevReportID) { return; } - - if (isUnread(report, transactionThreadReport) || (lastAction && isCurrentActionUnread(report, lastAction))) { + const hasAnyUnreadActions = sortedReportActions.some((action) => isReportActionUnread(action, report?.lastReadTime ?? '')); + if (isUnread(report, transactionThreadReport) || (lastAction && isCurrentActionUnread(report, lastAction)) || hasAnyUnreadActions) { // On desktop, when the notification center is displayed, isVisible will return false. // Currently, there's no programmatic way to dismiss the notification center panel. // To handle this, we use the 'referrer' parameter to check if the current navigation is triggered from a notification. From 1e110f5f7861555dfe36708e693e16c0852e04ca Mon Sep 17 00:00:00 2001 From: I Nyoman Jyotisa Date: Thu, 17 Jul 2025 14:27:48 +0800 Subject: [PATCH 3/4] lint fix --- .../MoneyRequestReportView/MoneyRequestReportActionsList.tsx | 1 + src/pages/home/report/ReportActionsList.tsx | 1 + 2 files changed, 2 insertions(+) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx index a8c4e5ed9068..5841a9548958 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx @@ -258,6 +258,7 @@ function MoneyRequestReportActionsList({ useEffect(() => { const hasAnyUnreadActions = reportActions.some((action) => isReportActionUnread(action, report?.lastReadTime ?? '')); + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing if (isUnread(report, transactionThreadReport) || (lastAction && isCurrentActionUnread(report, lastAction)) || hasAnyUnreadActions) { // On desktop, when the notification center is displayed, isVisible will return false. // Currently, there's no programmatic way to dismiss the notification center panel. diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index fc58f90d6d5f..da45dd3b75cb 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -368,6 +368,7 @@ function ReportActionsList({ return; } const hasAnyUnreadActions = sortedReportActions.some((action) => isReportActionUnread(action, report?.lastReadTime ?? '')); + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing if (isUnread(report, transactionThreadReport) || (lastAction && isCurrentActionUnread(report, lastAction)) || hasAnyUnreadActions) { // On desktop, when the notification center is displayed, isVisible will return false. // Currently, there's no programmatic way to dismiss the notification center panel. From 0f1ae768621b26ec094c110c2f3f6fd0ace4762f Mon Sep 17 00:00:00 2001 From: I Nyoman Jyotisa Date: Tue, 22 Jul 2025 15:26:53 +0800 Subject: [PATCH 4/4] Fix: New message marker is not displayed on the first message in expense report --- .../MoneyRequestReportView/MoneyRequestReportActionsList.tsx | 5 +---- src/libs/ReportActionsUtils.ts | 4 ++-- src/pages/home/report/ReportActionsList.tsx | 5 +---- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx index 5841a9548958..03f370760d78 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx @@ -41,7 +41,6 @@ import { isCurrentActionUnread, isDeletedParentAction, isIOUActionMatchingTransactionList, - isReportActionUnread, shouldReportActionBeVisible, wasMessageReceivedWhileOffline, } from '@libs/ReportActionsUtils'; @@ -257,9 +256,7 @@ function MoneyRequestReportActionsList({ }, []); useEffect(() => { - const hasAnyUnreadActions = reportActions.some((action) => isReportActionUnread(action, report?.lastReadTime ?? '')); - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if (isUnread(report, transactionThreadReport) || (lastAction && isCurrentActionUnread(report, lastAction)) || hasAnyUnreadActions) { + if (isUnread(report, transactionThreadReport) || (lastAction && isCurrentActionUnread(report, lastAction, visibleReportActions))) { // On desktop, when the notification center is displayed, isVisible will return false. // Currently, there's no programmatic way to dismiss the notification center panel. // To handle this, we use the 'referrer' parameter to check if the current navigation is triggered from a notification. diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index ef9f790fb46e..fccfd17df1e0 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1881,9 +1881,9 @@ function isReportActionUnread(reportAction: OnyxEntry, lastReadTim * Check whether the current report action of the report is unread or not * */ -function isCurrentActionUnread(report: OnyxEntry, reportAction: ReportAction): boolean { +function isCurrentActionUnread(report: OnyxEntry, reportAction: ReportAction, visibleReportActions?: ReportAction[]): boolean { const lastReadTime = report?.lastReadTime ?? ''; - const sortedReportActions = getSortedReportActions(Object.values(getAllReportActions(report?.reportID))); + const sortedReportActions = visibleReportActions ?? getSortedReportActions(Object.values(getAllReportActions(report?.reportID))); const currentActionIndex = sortedReportActions.findIndex((action) => action.reportActionID === reportAction.reportActionID); if (currentActionIndex === -1) { return false; diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index da45dd3b75cb..8843bad4f346 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -32,7 +32,6 @@ import { isConsecutiveChronosAutomaticTimerAction, isCurrentActionUnread, isDeletedParentAction, - isReportActionUnread, isReportPreviewAction, isReversedTransaction, isTransactionThread, @@ -367,9 +366,7 @@ function ReportActionsList({ if (report.reportID !== prevReportID) { return; } - const hasAnyUnreadActions = sortedReportActions.some((action) => isReportActionUnread(action, report?.lastReadTime ?? '')); - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if (isUnread(report, transactionThreadReport) || (lastAction && isCurrentActionUnread(report, lastAction)) || hasAnyUnreadActions) { + if (isUnread(report, transactionThreadReport) || (lastAction && isCurrentActionUnread(report, lastAction, sortedVisibleReportActions))) { // On desktop, when the notification center is displayed, isVisible will return false. // Currently, there's no programmatic way to dismiss the notification center panel. // To handle this, we use the 'referrer' parameter to check if the current navigation is triggered from a notification.