From 0d70f7807453d57f5e5a254a3ec7fc3ec3fcb9eb Mon Sep 17 00:00:00 2001 From: lorretheboy Date: Fri, 24 Oct 2025 23:46:55 +0800 Subject: [PATCH 1/2] fix: read message indicator shows for anonymous user --- src/pages/home/report/ReportActionsList.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index 51598c08bdd4..612ae14b6b5d 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -13,6 +13,7 @@ import {AUTOSCROLL_TO_TOP_THRESHOLD} from '@components/InvertedFlatList/BaseInve import {PersonalDetailsContext, usePersonalDetails} from '@components/OnyxListItemProvider'; import ReportActionsSkeletonView from '@components/ReportActionsSkeletonView'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; +import useIsAnonymousUser from '@hooks/useIsAnonymousUser'; import useLocalize from '@hooks/useLocalize'; import useNetworkWithOfflineStatus from '@hooks/useNetworkWithOfflineStatus'; import useOnyx from '@hooks/useOnyx'; @@ -202,6 +203,7 @@ function ReportActionsList({ const shouldFocusToTopOnMount = useMemo(() => isTransactionThreadReport || isMoneyRequestOrInvoiceReport, [isMoneyRequestOrInvoiceReport, isTransactionThreadReport]); const topReportAction = sortedVisibleReportActions.at(-1); const [shouldScrollToEndAfterLayout, setShouldScrollToEndAfterLayout] = useState(shouldFocusToTopOnMount && !reportActionID); + const isAnonymousUser = useIsAnonymousUser(); useEffect(() => { const unsubscribe = Visibility.onVisibilityChange(() => { @@ -267,6 +269,10 @@ function ReportActionsList({ * The reportActionID the unread marker should display above */ const [unreadMarkerReportActionID, unreadMarkerReportActionIndex] = useMemo(() => { + if (isAnonymousUser) { + return [null, -1]; + } + // If there are message that were received while offline, // we can skip checking all messages later than the earliest received offline message. const startIndex = earliestReceivedOfflineMessageIndex ?? 0; @@ -303,6 +309,10 @@ function ReportActionsList({ * Subscribe to read/unread events and update our unreadMarkerTime */ useEffect(() => { + if (isAnonymousUser) { + return; + } + const unreadActionSubscription = DeviceEventEmitter.addListener(`unreadAction_${report.reportID}`, (newLastReadTime: string) => { setUnreadMarkerTime(newLastReadTime); userActiveSince.current = DateUtils.getDBTime(); @@ -324,7 +334,7 @@ function ReportActionsList({ * lastReadTime. */ useLayoutEffect(() => { - if (unreadMarkerReportActionID) { + if (isAnonymousUser || unreadMarkerReportActionID) { return; } From 62c2b8877f8546a6f4fb38d40a7c561a886ccee5 Mon Sep 17 00:00:00 2001 From: lorretheboy Date: Sun, 26 Oct 2025 20:43:26 +0800 Subject: [PATCH 2/2] fix: lint --- src/pages/home/report/ReportActionsList.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index 612ae14b6b5d..3a47276b643b 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -302,7 +302,7 @@ function ReportActionsList({ } return [null, -1]; - }, [accountID, earliestReceivedOfflineMessageIndex, prevSortedVisibleReportActionsObjects, sortedVisibleReportActions, unreadMarkerTime]); + }, [accountID, isAnonymousUser, earliestReceivedOfflineMessageIndex, prevSortedVisibleReportActionsObjects, sortedVisibleReportActions, unreadMarkerTime]); prevUnreadMarkerReportActionID.current = unreadMarkerReportActionID; /** @@ -325,7 +325,7 @@ function ReportActionsList({ unreadActionSubscription.remove(); readNewestActionSubscription.remove(); }; - }, [report.reportID]); + }, [report.reportID, isAnonymousUser]); /** * When the user reads a new message as it is received, we'll push the unreadMarkerTime down to the timestamp of