Skip to content

[Due for payment 2026-09-10] [$500] LHN - Report Remains Marked as Unread After Returning Online Despite Message Being Read Offline #79837

Closed

Description

@lanitochka17

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.3.4-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #79632
Email or phone of affected tester (no customers): applausetester+dp501@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Mac / Safari
App Component: Left Hand Navigation (LHN)

Action Performed:

  1. Create a report with multiple expense items.
  2. Open the report.
  3. Switch the app to offline mode.
  4. Send several messages within the report.
  5. Mark the last message as unread.
  6. Navigate to the Inbox, then reopen the same report so the message becomes marked as read.
  7. Open any other report.
  8. Switch the app back online.

Expected Result:

The report should be displayed as read in the LHN, since the message was opened and read before going online.

Actual Result:

After returning online, the report is displayed as unread (bold) in the LHN, even though the message was previously read.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7051514_1768614481972.5_36_PM_2026-01-16.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022014478668144857937
  • Upwork Job ID: 2014478668144857937
  • Last Price Increase: 2026-02-25
  • Automatic offers:
    • situchan | Contributor | 110268112
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jan 18, 2026
  2. melvin-bot commented on Jan 18, 2026

    @melvin-bot

    Triggered auto assignment to @stephanieelliott (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jan 22, 2026
  4. changed the title [-]LHN - Report Remains Marked as Unread After Returning Online Despite Message Being Read Offline[/-] [+][$250] LHN - Report Remains Marked as Unread After Returning Online Despite Message Being Read Offline[/+] on Jan 22, 2026
  5. melvin-bot commented on Jan 22, 2026

    @melvin-bot
  6. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jan 22, 2026
  7. melvin-bot commented on Jan 22, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 (External)

  8. marufsharifi commented on Jan 24, 2026

    @marufsharifi

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    In the OP repro, a report is read while offline after offline-authored messages exist, but after reconnect it can appear unread again in LHN. The correct behavior is: messages the user already read before reconnect must stay read, while another participant's genuinely unseen message in the same report must still remain unread.

    What is the root cause of that problem?

    The current unread model relies on replay-time transport timestamps instead of a canonical unread timestamp.

    1. readNewestAction() snapshots a single lastReadTime value and bakes it into the queued request when the user reads the report offline:

    function readNewestAction(reportID: string | undefined, hasOnceLoadedReportActions: boolean, shouldResetUnreadMarker = false) {
    if (!reportID) {
    return;
    }
    // Do not try to mark the report as read if the report has not been loaded and shared with the user
    if (!hasOnceLoadedReportActions) {
    return;
    }
    const lastReadTime = NetworkConnection.getDBTimeWithSkew();
    const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT>> = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
    value: {
    lastReadTime,
    },
    },
    ];
    const parameters: ReadNewestActionParams = {
    reportID,
    lastReadTime,
    };

    1. Report-level unread still compares lastReadTime only against lastVisibleActionCreated:

    App/src/libs/ReportUtils.ts

    Lines 9011 to 9029 in 84815b8

    function isUnread(report: OnyxEntry<Report>, oneTransactionThreadReport: OnyxEntry<Report>, isReportArchived: boolean | undefined): boolean {
    if (!report) {
    return false;
    }
    if (isEmptyReport(report, isReportArchived)) {
    return false;
    }
    if (!report.lastReadTime) {
    return true;
    }
    // lastVisibleActionCreated and lastReadTime are both datetime strings and can be compared directly
    const lastVisibleActionCreated = getReportLastVisibleActionCreated(report, oneTransactionThreadReport);
    const lastReadTime = report.lastReadTime ?? '';
    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;

    1. Action-level unread still compares lastReadTime only against reportAction.created:

    function isReportActionUnread(reportAction: OnyxEntry<ReportAction>, lastReadTime?: string) {
    if (!lastReadTime) {
    return !isCreatedAction(reportAction);
    }
    return !!(reportAction && lastReadTime && reportAction.created && lastReadTime < reportAction.created);

    1. The unread marker and app-visibility read logic also advance from created timestamps in the two report action lists:

    1_

    setUnreadMarkerTime(newLastReadTime);
    });
    return () => {
    unreadActionSubscription.remove();
    readNewestActionSubscription.remove();
    };
    }, [report.reportID, isAnonymousUser]);
    /**
    * When the user reads a new message as it is received, we'll push the unreadMarkerTime down to the timestamp of
    * the latest report action. When new report actions are received and the user is not viewing them (they're above
    * the MSG_VISIBLE_THRESHOLD), the unread marker will display over those new messages rather than the initial
    * lastReadTime.
    */
    useLayoutEffect(() => {
    if (isAnonymousUser || unreadMarkerReportActionID) {
    return;
    }
    const mostRecentReportActionCreated = lastAction?.created ?? '';
    if (mostRecentReportActionCreated <= unreadMarkerTime) {
    return;
    }
    setUnreadMarkerTime(mostRecentReportActionCreated);
    // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [lastAction?.created]);
    const lastVisibleActionCreated = getReportLastVisibleActionCreated(report, transactionThreadReport);
    const hasNewestReportAction = lastAction?.created === lastVisibleActionCreated || isReportPreviewAction(lastAction);
    const hasNewestReportActionRef = useRef(hasNewestReportAction);
    hasNewestReportActionRef.current = hasNewestReportAction;
    const sortedVisibleReportActionsRef = useRef(sortedVisibleReportActions);
    const maybeLoadChatsOnScroll = useCallback(
    (event: NativeSyntheticEvent<NativeScrollEvent>) => {
    const {
    contentOffset: {y},
    contentSize: {height: contentHeight},
    layoutMeasurement: {height: layoutHeight},
    } = event.nativeEvent;
    const distanceFromTop = y;
    const distanceFromBottom = contentHeight - layoutHeight - y;
    if (distanceFromTop <= 0) {
    if (!hasTriggeredTopPagination.current) {
    hasTriggeredTopPagination.current = true;
    loadNewerChats(false);
    }
    } else {
    hasTriggeredTopPagination.current = false;
    }
    if (distanceFromBottom <= 0) {
    if (!hasTriggeredBottomPagination.current) {
    hasTriggeredBottomPagination.current = true;
    if (!isSearchTopmostFullScreenRoute()) {
    loadOlderChats(false);
    return;
    }
    // eslint-disable-next-line @typescript-eslint/no-deprecated
    InteractionManager.runAfterInteractions(() => requestAnimationFrame(() => loadOlderChats(false)));
    }
    } else {
    hasTriggeredBottomPagination.current = false;
    }
    },
    [loadNewerChats, loadOlderChats],
    );
    const {isFloatingMessageCounterVisible, setIsFloatingMessageCounterVisible, trackVerticalScrolling, onViewableItemsChanged} = useReportUnreadMessageScrollTracking({
    reportID: report.reportID,
    currentVerticalScrollingOffsetRef: scrollingVerticalOffset,
    readActionSkippedRef: readActionSkipped,
    unreadMarkerReportActionIndex,
    isInverted: false,
    onTrackScrolling: (event: NativeSyntheticEvent<NativeScrollEvent>) => {
    scrollingVerticalOffset.current = event.nativeEvent.contentOffset.y;
    maybeLoadChatsOnScroll(event);
    onScroll?.(event);
    if (shouldScrollToEndAfterLayout && (!hasCreatedActionAdded || isOffline)) {
    setShouldScrollToEndAfterLayout(false);
    }
    },
    hasOnceLoadedReportActions: !!reportMetadata?.hasOnceLoadedReportActions,
    });
    useScrollToEndOnNewMessageReceived({
    sizeChangeType: 'changed',
    scrollOffsetRef: scrollingVerticalOffset,
    lastActionID: lastAction?.reportActionID,
    visibleActionsLength: sortedVisibleReportActions.length,
    hasNewestReportAction,
    setIsFloatingMessageCounterVisible,
    scrollToEnd: reportScrollManager.scrollToBottom,
    resetKey: linkedReportActionID,
    });

    2_

    const lastVisibleActionCreated = getReportLastVisibleActionCreated(report, transactionThreadReport);
    const hasNewestReportAction = lastAction?.created === lastVisibleActionCreated;
    const userActiveSince = useRef<string>(DateUtils.getDBTime());
    const reportActionIDs = useMemo(() => {
    return reportActions?.map((action) => action.reportActionID) ?? [];
    }, [reportActions]);
    const {loadOlderChats, loadNewerChats} = useLoadReportActions({
    reportID,
    reportActions,
    allReportActionIDs: reportActionIDs,
    transactionThreadReport,
    hasOlderActions,
    hasNewerActions,
    newestFetchedReportActionID: reportMetadata?.newestFetchedReportActionID,
    });
    const hasFinishedInitialLoad = reportMetadata?.isLoadingInitialReportActions === false;
    const prevNewestFetchedIDRef = useRef<string | undefined>(undefined);
    useEffect(() => {
    if (hasFinishedInitialLoad && hasNewerActions && reportActions.length > 0 && !isOffline && !reportMetadata?.isLoadingNewerReportActions) {
    // Safety guard: if the cursor hasn't advanced since the last call, the server
    // isn't returning new data. Stop to prevent an infinite request loop.
    const currentCursor = reportMetadata?.newestFetchedReportActionID;
    if (prevNewestFetchedIDRef.current !== undefined && prevNewestFetchedIDRef.current === currentCursor) {
    return;
    }
    prevNewestFetchedIDRef.current = currentCursor;
    loadNewerChats(false);
    }
    }, [hasFinishedInitialLoad, reportActions.length, hasNewerActions, isOffline, reportMetadata?.isLoadingNewerReportActions, reportMetadata?.newestFetchedReportActionID, loadNewerChats]);
    const onStartReached = useCallback(() => {
    if (!isSearchTopmostFullScreenRoute()) {
    loadOlderChats(false);
    return;
    }
    // eslint-disable-next-line @typescript-eslint/no-deprecated
    InteractionManager.runAfterInteractions(() => requestAnimationFrame(() => loadOlderChats(false)));
    }, [loadOlderChats]);
    const onEndReached = useCallback(() => {
    loadNewerChats(false);
    }, [loadNewerChats]);
    const prevUnreadMarkerReportActionID = useRef<string | null>(null);
    const visibleActionsMap = useMemo(() => {
    return visibleReportActions.reduce((actionsMap, reportAction) => {
    Object.assign(actionsMap, {
    [reportAction.reportActionID]: reportAction,
    });
    return actionsMap;
    }, {} as OnyxTypes.ReportActions);
    }, [visibleReportActions]);
    const prevVisibleActionsMap = usePrevious(visibleActionsMap);
    const reportLastReadTime = report.lastReadTime ?? '';
    /**
    * The timestamp for the unread marker.
    *
    * This should ONLY be updated when the user
    * - switches reports
    * - marks a message as read/unread
    * - reads a new message as it is received
    */
    const [unreadMarkerTime, setUnreadMarkerTime] = useState(reportLastReadTime);
    useEffect(() => {
    setUnreadMarkerTime(reportLastReadTime);
    // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [report.reportID]);
    useEffect(() => {
    const unsubscribe = Visibility.onVisibilityChange(() => {
    setIsVisible(Visibility.isVisible());
    });
    return unsubscribe;
    }, []);
    useEffect(() => {
    if (!isFocused) {
    return;
    }
    if (isUnread(report, transactionThreadReport, isReportArchived) || (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.
    const isFromNotification = route?.params?.referrer === CONST.REFERRER.NOTIFICATION;
    if ((isVisible || isFromNotification) && scrollingVerticalBottomOffset.current < CONST.REPORT.ACTIONS.ACTION_VISIBLE_THRESHOLD) {
    readNewestAction(report.reportID, !!reportMetadata?.hasOnceLoadedReportActions);
    if (isFromNotification) {
    Navigation.setParams({referrer: undefined});
    }
    } else {
    readActionSkipped.current = true;
    }
    }
    // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [report.lastVisibleActionCreated, transactionThreadReport?.lastVisibleActionCreated, report.reportID, isVisible, reportMetadata?.hasOnceLoadedReportActions]);
    useEffect(() => {
    if (!isVisible || !isFocused) {
    if (!lastMessageTime.current) {
    lastMessageTime.current = lastAction?.created ?? '';
    }
    return;
    }
    // In case the user read new messages (after being inactive) with other device we should
    // show marker based on report.lastReadTime
    const newMessageTimeReference = lastMessageTime.current && report.lastReadTime && lastMessageTime.current > report.lastReadTime ? userActiveSince.current : report.lastReadTime;
    lastMessageTime.current = null;
    const hasNewMessagesInView = scrollingVerticalBottomOffset.current < CONST.REPORT.ACTIONS.ACTION_VISIBLE_THRESHOLD;
    const hasUnreadReportAction = reportActions.some(
    (reportAction) => newMessageTimeReference && newMessageTimeReference < reportAction.created && reportAction.actorAccountID !== currentUserAccountID,
    );
    if (!hasNewMessagesInView || !hasUnreadReportAction) {
    return;
    }
    readNewestAction(report.reportID, !!reportMetadata?.hasOnceLoadedReportActions);
    userActiveSince.current = DateUtils.getDBTime();
    // This effect logic to `mark as read` will only run when the report focused has new messages and the App visibility
    // is changed to visible(meaning user switched to app/web, while user was previously using different tab or application).
    // We will mark the report as read in the above case which marks the LHN report item as read while showing the new message
    // marker for the chat messages received while the user wasn't focused on the report or on another browser tab for web.
    // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [isFocused, isVisible, reportMetadata?.hasOnceLoadedReportActions]);
    /**
    * The index of the earliest message that was received while offline
    */
    const earliestReceivedOfflineMessageIndex = useMemo(() => {
    const lastIndex = reportActions.findLastIndex((action) => {
    return wasMessageReceivedWhileOffline(action, isOffline, lastOfflineAt.current, lastOnlineAt.current, getLocalDateFromDatetime);
    });
    // The last index in the list is the earliest message that was received while offline
    return lastIndex > -1 ? lastIndex : undefined;
    }, [getLocalDateFromDatetime, isOffline, lastOfflineAt, lastOnlineAt, reportActions]);
    /**
    * The reportActionID the unread marker should display above
    */
    const [unreadMarkerReportActionID, unreadMarkerReportActionIndex] = getUnreadMarkerReportAction({
    visibleReportActions,
    earliestReceivedOfflineMessageIndex,
    currentUserAccountID,
    prevSortedVisibleReportActionsObjects: prevVisibleActionsMap,
    unreadMarkerTime,
    scrollingVerticalOffset: scrollingVerticalBottomOffset.current,
    prevUnreadMarkerReportActionID: prevUnreadMarkerReportActionID.current,
    isOffline,
    isReversed: true,
    });
    prevUnreadMarkerReportActionID.current = unreadMarkerReportActionID;
    const {isFloatingMessageCounterVisible, setIsFloatingMessageCounterVisible, trackVerticalScrolling, onViewableItemsChanged} = useReportUnreadMessageScrollTracking({
    reportID: report.reportID,
    currentVerticalScrollingOffsetRef: scrollingVerticalBottomOffset,
    readActionSkippedRef: readActionSkipped,
    unreadMarkerReportActionIndex,
    isInverted: false,
    onTrackScrolling: (event: NativeSyntheticEvent<NativeScrollEvent>) => {
    const {layoutMeasurement, contentSize, contentOffset} = event.nativeEvent;
    const fullContentHeight = contentSize.height;
    /**
    * Count the diff between current scroll position and the bottom of the list.
    * Diff == (height of all items in the list) - (height of the layout with the list) - (how far user scrolled)
    */
    scrollingVerticalBottomOffset.current = fullContentHeight - layoutMeasurement.height - contentOffset.y;
    scrollOffsetRef.current = scrollingVerticalBottomOffset.current;
    // We additionally track the top offset to be able to scroll to the new transaction when it's added
    scrollingVerticalTopOffset.current = contentOffset.y;
    },
    hasOnceLoadedReportActions: !!reportMetadata?.hasOnceLoadedReportActions,
    });
    useScrollToEndOnNewMessageReceived({
    sizeChangeType: 'grewFromReportActions',
    scrollOffsetRef,
    lastActionID: lastAction?.reportActionID,
    visibleActionsLength: visibleReportActions.length,
    reportActionsLength: reportActions.length,
    hasNewestReportAction,
    setIsFloatingMessageCounterVisible,
    scrollToEnd: reportScrollManager.scrollToEnd,
    });
    /**
    * Subscribe to read/unread events and update our unreadMarkerTime
    */
    useEffect(() => {
    const unreadActionSubscription = DeviceEventEmitter.addListener(`unreadAction_${report.reportID}`, (newLastReadTime: string) => {
    setUnreadMarkerTime(newLastReadTime);
    userActiveSince.current = DateUtils.getDBTime();
    });
    const readNewestActionSubscription = DeviceEventEmitter.addListener(`readNewestAction_${report.reportID}`, (newLastReadTime: string) => {
    setUnreadMarkerTime(newLastReadTime);
    });
    return () => {
    unreadActionSubscription.remove();
    readNewestActionSubscription.remove();
    };
    }, [report.reportID]);
    /**
    * When the user reads a new message as it is received, we'll push the unreadMarkerTime down to the timestamp of
    * the latest report action. When new report actions are received and the user is not viewing them (they're above
    * the MSG_VISIBLE_THRESHOLD), the unread marker will display over those new messages rather than the initial
    * lastReadTime.
    */
    useLayoutEffect(() => {
    if (unreadMarkerReportActionID) {
    return;
    }
    const mostRecentReportActionCreated = lastAction?.created ?? '';
    if (mostRecentReportActionCreated <= unreadMarkerTime) {
    return;
    }
    setUnreadMarkerTime(mostRecentReportActionCreated);

    That works only if created is already the correct unread boundary. In this issue it is not, because offline-authored visible actions can receive newer server created timestamps when they replay online, while the queued read boundary remains the older offline value.

    As pointed out, swapping steps 3 and 4 makes the bug disappear. That only makes sense if the problem is tied to when the action timestamps become canonical: when messages are sent online first, the server timestamps already exist before the read boundary is captured.

    Also, as regression case shows, any fix that simply bumps the read boundary forward or hides unread based on actor identity can auto-read another user's unseen message in the same report. So the real problem is not “self-authored messages should be treated as read”. The real problem is that unread semantics currently infer correctness from replay-time created values, while the frontend needs a canonical unread timestamp that survives offline replay.

    What changes do you think we should make in order to solve the problem?

    The current implementation keeps ordering and sorting on created, but changes unread semantics to consume canonical unread timestamps when available, with full fallback to today's fields until backend support lands. Below are the local diffs from the current implementation.

    1. Add optional canonical unread-time fields to the FE contract.
    This gives unread logic a dedicated source-of-truth without changing request payloads or sorting behavior.

    diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts
    @@
             /** The time of the last message on the report */
             lastVisibleActionCreated?: string;
    +
    +        /** The canonical event time of the last visible action, used for unread semantics */
    +        lastVisibleActionOccurredAt?: string;
    diff --git a/src/types/onyx/ReportAction.ts b/src/types/onyx/ReportAction.ts
    @@
         /** ISO-formatted datetime */
         created: string;
    +
    +    /** Canonical event time used for unread semantics */
    +    occurredAt?: string;
    diff --git a/src/types/utils/whitelistedReportKeys.ts b/src/types/utils/whitelistedReportKeys.ts
    @@
             lastVisibleActionCreated: unknown;
    +        lastVisibleActionOccurredAt: unknown;

    2. Route report-level and action-level unread checks through shared fallback helpers.
    This keeps unread semantics centralized instead of letting each caller compare against replay-time created directly.

    diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts
    @@
    +function getReportActionOccurredAt(reportAction: OnyxEntry<ReportAction>) {
    +    return reportAction?.occurredAt ?? reportAction?.created ?? '';
    +}
    +
     function isReportActionUnread(reportAction: OnyxEntry<ReportAction>, lastReadTime?: string) {
    @@
    -    return !!(reportAction && lastReadTime && reportAction.created && lastReadTime < reportAction.created);
    +    const reportActionOccurredAt = getReportActionOccurredAt(reportAction);
    +    return !!(reportAction && lastReadTime && reportActionOccurredAt && lastReadTime < reportActionOccurredAt);
    diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts
    @@
    -    const lastVisibleActionCreated = getReportLastVisibleActionCreated(report, oneTransactionThreadReport);
    +    const lastVisibleActionOccurredAt = getReportLastVisibleActionOccurredAt(report, oneTransactionThreadReport);
    @@
    -    return lastReadTime < (lastVisibleActionCreated ?? '') || lastReadTime < lastMentionedTime;
    +    return lastReadTime < lastVisibleActionOccurredAt || lastReadTime < lastMentionedTime;
    @@
    +function getReportLastVisibleActionOccurredAt(report: OnyxEntry<Report>, oneTransactionThreadReport: OnyxEntry<Report>) {
    +    const reportLastVisibleActionOccurredAt = report?.lastVisibleActionOccurredAt ?? report?.lastVisibleActionCreated ?? '';
    +    const threadLastVisibleActionOccurredAt =
    +        oneTransactionThreadReport?.lastVisibleActionOccurredAt ?? oneTransactionThreadReport?.lastVisibleActionCreated ?? '';
    +    return reportLastVisibleActionOccurredAt > threadLastVisibleActionOccurredAt ? reportLastVisibleActionOccurredAt : threadLastVisibleActionOccurredAt;
    +}

    3. Update unread consumers to use the effective unread timestamp, while keeping ordering on created.
    This changes only unread-marker time, app-visibility read logic, and unread badges. It does not turn occurredAt into a new list-sorting field.

    diff --git a/src/pages/inbox/report/ReportActionsList.tsx b/src/pages/inbox/report/ReportActionsList.tsx
    @@
    +    const lastVisibleActionOccurredAt = getReportLastVisibleActionOccurredAt(report, transactionThreadReport);
    +    const lastActionOccurredAt = getReportActionOccurredAt(lastAction);
    @@
    -        const mostRecentReportActionCreated = lastAction?.created ?? '';
    -        if (mostRecentReportActionCreated <= unreadMarkerTime) {
    +        if (lastActionOccurredAt <= unreadMarkerTime) {
                 return;
             }
     
    -        setUnreadMarkerTime(mostRecentReportActionCreated);
    +        setUnreadMarkerTime(lastActionOccurredAt);
    @@
    -    }, [report.lastVisibleActionCreated, transactionThreadReport?.lastVisibleActionCreated, report.reportID, isVisible, reportMetadata?.hasOnceLoadedReportActions]);
    +    }, [lastVisibleActionOccurredAt, report.reportID, isVisible, reportMetadata?.hasOnceLoadedReportActions]);
    @@
    -                lastMessageTime.current = lastAction?.created ?? '';
    +                lastMessageTime.current = lastActionOccurredAt;
    @@
    -                newMessageTimeReference < reportAction.created &&
    +                newMessageTimeReference < getReportActionOccurredAt(reportAction) &&
    diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx
    @@
    +    const lastVisibleActionOccurredAt = getReportLastVisibleActionOccurredAt(report, transactionThreadReport);
    +    const lastActionOccurredAt = getReportActionOccurredAt(lastAction);
    @@
    -    }, [report.lastVisibleActionCreated, transactionThreadReport?.lastVisibleActionCreated, report.reportID, isVisible, reportMetadata?.hasOnceLoadedReportActions]);
    +    }, [lastVisibleActionOccurredAt, report.reportID, isVisible, reportMetadata?.hasOnceLoadedReportActions]);
    @@
    -                lastMessageTime.current = lastAction?.created ?? '';
    +                lastMessageTime.current = lastActionOccurredAt;
    @@
    -            (reportAction) => newMessageTimeReference && newMessageTimeReference < reportAction.created && reportAction.actorAccountID !== currentUserAccountID,
    +            (reportAction) => newMessageTimeReference && newMessageTimeReference < getReportActionOccurredAt(reportAction) && reportAction.actorAccountID !== currentUserAccountID,
    @@
    -        const mostRecentReportActionCreated = lastAction?.created ?? '';
    -        if (mostRecentReportActionCreated <= unreadMarkerTime) {
    +        if (lastActionOccurredAt <= unreadMarkerTime) {
                 return;
             }
     
    -        setUnreadMarkerTime(mostRecentReportActionCreated);
    +        setUnreadMarkerTime(lastActionOccurredAt);
    diff --git a/src/components/TransactionItemRow/DataCells/ChatBubbleCell.tsx b/src/components/TransactionItemRow/DataCells/ChatBubbleCell.tsx
    @@
    -const isReportUnread = ({lastReadTime = '', lastVisibleActionCreated = '', lastMentionedTime = ''}: Report): boolean =>
    -    lastReadTime < lastVisibleActionCreated || lastReadTime < (lastMentionedTime ?? '');
    +const isReportUnread = ({lastReadTime = '', lastVisibleActionOccurredAt = '', lastVisibleActionCreated = '', lastMentionedTime = ''}: Report): boolean =>
    +    lastReadTime < (lastVisibleActionOccurredAt || lastVisibleActionCreated) || lastReadTime < (lastMentionedTime ?? '');
    diff --git a/src/pages/inbox/report/shouldDisplayNewMarkerOnReportAction.ts b/src/pages/inbox/report/shouldDisplayNewMarkerOnReportAction.ts
    @@
    -    // The unread marker will show if the action's `created` time is later than `unreadMarkerTime`.
    +    // The unread marker will show if the action's effective unread timestamp is later than `unreadMarkerTime`.

    4. Keep action-side read/unread operations consistent with the same helper.
    This is not a queue fix. It simply makes manual unread and delayed-notification logic respect the same effective unread timestamp used everywhere else.

    diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts
    @@
    -            (!latest || current.created > latest.created) &&
    +            (!latest || ReportActionsUtils.getReportActionOccurredAt(current) > ReportActionsUtils.getReportActionOccurredAt(latest)) &&
    @@
    -    const actionCreationTime =
    -        reportAction?.created || (latestReportActionFromOtherUsers?.created ?? getReportLastVisibleActionCreated(report, transactionThreadReport) ?? DateUtils.getDBTime(0));
    +    const actionCreationTime =
    +        ReportActionsUtils.getReportActionOccurredAt(reportAction) ||
    +        ReportActionsUtils.getReportActionOccurredAt(latestReportActionFromOtherUsers) ||
    +        getReportLastVisibleActionOccurredAt(report, transactionThreadReport) ||
    +        DateUtils.getDBTime(0);
    @@
    -    if (action && report?.lastReadTime && report.lastReadTime >= action.created) {
    -        Log.info(`${tag} No notification because the comment was already read`, false, {created: action.created, lastReadTime: report.lastReadTime});
    +    const actionOccurredAt = ReportActionsUtils.getReportActionOccurredAt(action);
    +    if (action && report?.lastReadTime && report.lastReadTime >= actionOccurredAt) {
    +        Log.info(`${tag} No notification because the comment was already read`, false, {occurredAt: actionOccurredAt, created: action.created, lastReadTime: report.lastReadTime});
             return false;
         }

    5. Add focused tests that prove precedence and fallback behavior.
    These tests verify the new canonical field precedence without changing unrelated ordering behavior.

    diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts
    @@
    +    it('should prefer lastVisibleActionOccurredAt when determining whether a report is unread', () => {
    +        const report = {
    +            reportID: '1',
    +            lastMessageText: 'Test message',
    +            lastReadTime: '2024-01-01 10:00:00.000',
    +            lastVisibleActionCreated: '2024-01-01 10:05:00.000',
    +            lastVisibleActionOccurredAt: '2024-01-01 09:59:59.999',
    +        } as OnyxTypes.Report;
    +
    +        expect(ReportUtils.isUnread(report, undefined, undefined)).toBe(false);
    +    });
    +
    +    it('should fall back to lastVisibleActionCreated when no canonical unread time is available', () => {
    +        const report = {
    +            reportID: '1',
    +            lastMessageText: 'Test message',
    +            lastReadTime: '2024-01-01 10:00:00.000',
    +            lastVisibleActionCreated: '2024-01-01 10:05:00.000',
    +        } as OnyxTypes.Report;
    +
    +        expect(ReportUtils.isUnread(report, undefined, undefined)).toBe(true);
    +    });
    diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts
    @@
    +    describe('isReportActionUnread', () => {
    +        it('should prefer occurredAt when available', () => {
    +            const reportAction = {
    +                actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
    +                created: '2024-01-01 10:05:00.000',
    +                occurredAt: '2024-01-01 10:00:00.000',
    +                message: [{type: 'COMMENT', html: 'Test', text: 'Test'}],
    +                reportActionID: '1',
    +                shouldShow: true,
    +            } as ReportAction;
    +
    +            expect(ReportActionsUtils.isReportActionUnread(reportAction, '2024-01-01 10:02:00.000')).toBe(false);
    +            expect(ReportActionsUtils.isReportActionUnread(reportAction, '2024-01-01 09:59:59.999')).toBe(true);
    +        });
    +
    +        it('should fall back to created when occurredAt is missing', () => {
    +            const reportAction = {
    +                actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
    +                created: '2024-01-01 10:05:00.000',
    +                message: [{type: 'COMMENT', html: 'Test', text: 'Test'}],
    +                reportActionID: '1',
    +                shouldShow: true,
    +            } as ReportAction;
    +
    +            expect(ReportActionsUtils.isReportActionUnread(reportAction, '2024-01-01 10:04:59.999')).toBe(true);
    +            expect(ReportActionsUtils.isReportActionUnread(reportAction, '2024-01-01 10:05:00.000')).toBe(false);
    +        });
    +    });

    Why this is best practice. This fixes unread behavior at the source-of-truth unread layer instead of masking it in the UI or mutating one specific queued API request. It avoids unique client-side handling for ReadNewestAction, does not mutate queued transport requests, does not hide unread based on actor identity, and remains backward compatible until backend data is available.

    Backend dependency. The FE implementation is already safe because every helper falls back to created / lastVisibleActionCreated when the new fields are absent. To fully solve the issue, backend still needs to emit ReportAction.occurredAt and Report.lastVisibleActionOccurredAt in HTTPS and Pusher onyxData, deriving them from a canonical event-time source. For client-authored visible actions, that canonical time should come from validated clientCreatedTime when available, otherwise fall back to server created. No FE request shape changes are needed.

    What alternative solutions did you explore? (Optional)

  9. github-actions commented on Jan 24, 2026

    @github-actions
    Contributor

    ⚠️ @marufsharifi Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  10. marufsharifi commented on Jan 24, 2026

    @marufsharifi

    Solution demo:

    ProposalDemo.mp4
  11. 181 remaining items

  12. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Sep 7, 2026
  13. melvin-bot commented on Sep 9, 2026

    @melvin-bot

    Current assignee @mallenexpensify is eligible for the Awaiting Payment assigner, not assigning anyone new.

  14. melvin-bot commented on Sep 14, 2026

    @melvin-bot

    @mallenexpensify Eep! 4 days overdue now. Issues have feelings too...

  15. mallenexpensify commented on Sep 14, 2026

    @mallenexpensify
    Contributor

    Claude posting on behalf of Matt:

    $500 to @abbasifaizan70 (Contributor) and $500 to @situchan (Contributor+).

    Contributor @abbasifaizan70 due $500 via Upwork, 100%
    Contributor+ @situchan due $500 via NewDot, 100%
    Job price $500, from the title
    Reduction None
    Increase None
    Blockers 1 linked, rebutted
    Precedent #76921, the ladder runs off the title price, not the standard price
    Needs a ruling No

    To pay, copy this block and paste it into the comment box:

    ### Payment Summary
    Contributor: @abbasifaizan70 paid $500 via Upwork
    Contributor+: @situchan due $500 via NewDot
    
    How the amount is reached
    PR #94738, author @abbasifaizan70
    Size 2 files, +326 / -0
    C+ checklist on this issue Posted by @situchan, all boxes checked, with a regression test proposal
    Reviewer checklist on the PR Posted by @situchan, all boxes checked
    Platform evidence 5 of 5 boxes checked, 5 of 5 carry a video
    • Job price $500, taken from the title. This is the only issue in today's batch above the standard amount, and the percentage runs off $500, not off the standard price.
    • Both payees 100%. No reduction applies. The checklist is complete with evidence on all five platforms.
    • No regression cut. #100257 was auto-linked here and has been traced elsewhere to Mobile-Expensify#14097, with @JS00001 calling it an "Unrelated blocker".
    • No increase. 2 files and +326 lines sit below the 25 file and 1000 line thresholds.

    Note on the rail. @abbasifaizan70 is a Contributor, so the block above says "paid via Upwork". Change it to NewDot if he is not on an Upwork contract.

    There is no Melvin payment summary on this issue. The payees above come from the assignees and the posted checklist. Worth a sanity check before paying.


    Claude posting on behalf of Matt. PAYRUBRICTEST v2

  16. mallenexpensify commented on Sep 15, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @abbasifaizan70 paid $500 via Upwork
    Contributor+: @situchan due $500 via NewDot

    @abbasifaizan70 can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022099659017576756604

  17. abbasifaizan70 commented on Sep 15, 2026

    @abbasifaizan70
    Contributor

    @mallenexpensify offer accepted but it was for 250. submitted for payment

  18. mallenexpensify commented on Sep 15, 2026

    @mallenexpensify
    Contributor

    @abbasifaizan70 paid $500, summary updated above. Thx.

  19. laurenreidexpensify commented on Sep 28, 2026

    @laurenreidexpensify
    Contributor

    Approved $500 @situchan New Expensify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions