Skip to content

[Due for payment 2026-10-27] [$250] the conversation that requested the money is marked as read instead of unread #102117

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.4.92-5
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/folder/57602202/test-cases/41237827
Email or phone of affected tester (no customers): nathanmulugetatesting+2420735@gmail.com
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: macOS Tahoe
App Component: Left Hand Navigation (LHN)

Action Performed:

  1. [Account A] send an IOU to a non existent account B
  2. Sign out of account A (Do not switch to another tab or use another window)
  3. Sign in with account B
  4. Navigate to inbox

Expected Result:

The conversation with account A is marked as unread on LHN

Actual Result:

The conversation with account A is marked as read on LHN

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7267724_1790202447063.2026-09-24_01-20-17.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Mita Rachim
Bug ID: 7267724

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit

Activity

  1. applause-bot commented on Sep 24, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/726092c763a2f339444a1f6b0081de3a50c457e5ee85ba32ac9a4277630b26e3

  2. added
    Daily
    Bug
    on Sep 24, 2026
  3. MelvinBot commented on Sep 24, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    On a wide (desktop) layout the Inbox always mounts a report in the central pane, and merely mounting a report marks it as read — even though the user never opened it. So the chat with account A is auto-read within a second of B landing on the Inbox.

    The chain:

    1. The split navigator guarantees a central-pane REPORT screen whenever only the sidebar is present — SplitRouter.ts:111-126. This is wide-layout only, which matches the report being macOS/Chrome-only.
    2. Which report it shows comes from findLastAccessedReport. For a brand-new account there is no visit history, so it falls back to "the report with the newest lastReadTime" — ReportUtils.ts:2560-2567.
    3. ReportsSplitNavigator snapshots that ID in a useState initializer on the first render, with no "reports finished loading" guard — ReportsSplitNavigator.tsx:45-68. ReportRouteParamHandler does have that guard and its comment names this exact hazard: picking from a partially loaded collection "can pin a report that isn't really the last accessed one… Neither can be corrected later" — ReportRouteParamHandler.tsx:50-60.
    4. Mounting that screen fires openReport with shouldMarkAsRead defaulting to true (ReportFetchHandler.tsx:235-253), and the one-shot initial mark-as-read in useMarkAsRead.ts:171-194 calls readNewestAction. That effect has no screen-focus and no visibility check — unlike the other two mark-as-read effects in the same hook, which require isVisible && Visibility.hasFocus().
    5. readNewestAction writes lastReadTime = now and persists it to the server (Report/index.ts:3184-3216), so the chat is read permanently, not just visually.

    This also explains the odd precondition "do not switch to another tab or use another window": signing in in the same tab means no page reload, so the navigator mounts while B's reports are still streaming in from OpenApp — and at that instant the chat with A may be the only report present.

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

    Primary fix — a report the user did not explicitly open should not be marked as read. In useMarkAsRead.ts:171-194, gate the one-shot initial mark-as-read on the same conditions the other two effects already use (screen focused and window visible/focused). Today a report auto-mounted in the central pane — even one sitting behind an onboarding modal — is marked read.

    Secondary fix — stop the navigator from pinning a report chosen from a half-loaded collection. In ReportsSplitNavigator.tsx:45-68, apply the same isLoadingOnyxValue guard that ReportRouteParamHandler uses before locking in initialReportID.

    What alternative solutions did you explore?

    Alternatives considered and evidence

    Stale state left over from account A's session. Ruled out: KEYS_TO_PRESERVE_ON_SIGN_OUT (SignInRedirect.ts:55-67) preserves no report, route, or read-state key, and the navigation state is reset on sign-out (getStateToResetAfterLogout.ts:27-35). A's optimistic lastReadTime cannot survive into B's session.

    The sender's lastReadTime being sent to the server. Ruled out on the client: no IOU/money-request API parameter carries a read time — only ReadNewestActionParams, MarkAsUnreadParams, MarkAllMessagesAsReadParams, and OpenReportParams.clientLastReadTime do.

    Not fully ruled out (would need backend access): the server may already return a non-null lastReadTime for B's copy of the chat when it materialises the report for the newly created account. If so the fix is in Auth/Web-Expensify, not App, and needs an internal engineer. The decisive check is whether a ReadNewestAction request is sent for that report within seconds of B signing in (→ App bug, as proposed above) or whether lastReadTime is already set in the OpenApp response (→ backend bug).

    A second, independent way the row can render non-bold: the LHN requires a truthy lastActorAccountID — SidebarUtils.ts:839. If B's copy of the chat comes back without it, the row is not bold regardless of lastReadTime. Worth checking in Onyx during a repro.

    Verification status: I could not confirm this at runtime — the test session was handed over with the web app stuck on a blank page, so the repro was not executed. The conclusion rests on code reading only, hence medium confidence.

    Possibly related issues


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/102117) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run · no recording available

  4. added
    External
    on Sep 24, 2026
  5. melvin-bot commented on Sep 24, 2026

    @melvin-bot

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

  6. melvin-bot commented on Sep 24, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  7. M00rish commented on Sep 24, 2026

    @M00rish
    Contributor

    Melvin RCA doesn't hold. Nothing marks the chat as read. Reproduced on web and for the new user lastReadTime is unset and isUnread() returns true.

    The row isn't bold because the chat arrives with lastActorAccountID: "", and the LHN (and the Unread tab) also require that field:

    result.isUnread = isUnread(report, oneTransactionThreadReport, isReportArchived, reportAttributes?.isEmpty) && !!report.lastActorAccountID;

    !!report.lastActorAccountID &&

    Fix: also accept reports that hold a money request, in both places:

     result.isUnread = isUnread(report, oneTransactionThreadReport, isReportArchived, reportAttributes?.isEmpty) && (!!report.lastActorAccountID || !!report.iouReportID);
    isUnread(report, undefined, isReportArchived, derivedIsEmptyReport) &&
            (!!report.lastActorAccountID || !!report.iouReportID) &&
             getReportNotificationPreference(report) !== CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE
  8. ZhenjaHorbach commented on Sep 25, 2026

    @ZhenjaHorbach
    Contributor

    🆘 C+ Help Wanted

  9. added
    Help Wanted
    on Sep 25, 2026
  10. Abdulloh0109 commented on Sep 25, 2026

    @Abdulloh0109
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-09-25 17:50:13 UTC.

    Proposal

    Updated: my first version blamed useMarkAsRead. That was wrong. Nothing ever marks this chat as read, so I have replaced the root cause and the fix below.

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

    A brand-new account B receives a money request from A, signs in and opens the Inbox. The chat with A is shown as read in the LHN (not bold, missing from the Unread tab) even though B never opened it.

    What is the root cause of that problem?

    The chat really is unread. Only the UI hides it.

    B's copy of the chat comes back from OpenApp with:

    + lastReadTime: undefined              // B has read nothing
    + lastVisibleActionCreated: set        // A's REPORTPREVIEW is a real, visible message
    - lastActorAccountID: ""               // the actor lives on the IOU report, not on the chat

    isUnread() returns true for it, because there is no lastReadTime:

    App/src/libs/ReportUtils.ts

    Lines 9833 to 9845 in e029fad

    function isUnread(report: OnyxEntry<Report>, oneTransactionThreadReport: OnyxEntry<Report>, isReportArchived: boolean | undefined, derivedIsEmptyReport: boolean | undefined): boolean {
    if (!report) {
    return false;
    }
    if (isEmptyReport(report, isReportArchived, derivedIsEmptyReport)) {
    return false;
    }
    if (!report.lastReadTime) {
    return true;
    }
    // lastVisibleActionCreated and lastReadTime are both datetime strings and can be compared directly

    Three UI call sites then AND that result with !!report.lastActorAccountID. "" is falsy, so each one turns the chat back to "read":

    1. LHN row boldness, getOptionData:
      // When the only message of a report is deleted lastVisibleActionCreated is not reset leading to wrongly
      // setting it Unread so we add additional condition here to avoid empty chat LHN from being bold.
      result.isUnread = isUnread(report, oneTransactionThreadReport, isReportArchived, reportAttributes?.isEmpty) && !!report.lastActorAccountID;
    2. Unread tab filter, getIsUnreadReportForInboxTab:
      function getIsUnreadReportForInboxTab(report: Report, isReportArchived: boolean, derivedIsEmptyReport: boolean | undefined): boolean {
      // The `lastActorAccountID` guard matches getOptionData: it keeps chats whose only visible message was
      // deleted out of the Unread tab even though isUnread() can still be true (lastVisibleActionCreated isn't reset).
      return (
      isUnread(report, undefined, isReportArchived, derivedIsEmptyReport) &&
      !!report.lastActorAccountID &&
      getReportNotificationPreference(report) !== CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE
      );
    3. Bold rows in search / Start chat lists (shouldUnreadBeBold):
      isOptionUnread = isUnread(report, oneTransactionThreadReport, option.private_isArchived, reportAttributesDerived?.[report.reportID]?.isEmpty) && !!report.lastActorAccountID;

    The rest of the app has no such guard. UnreadIndicatorUpdater calls plain isUnread(), so the browser tab title still counts this chat as (1) while its LHN row is not bold. The app contradicts itself on the same screen:

    if (!ReportUtils.isUnread(report, oneTransactionThreadReport, isReportArchived, derivedIsEmptyReport)) {
    return false;
    }

    The same holds for the GSD IS_UNREAD reason in reasonForReportToBeInOptionList:

    App/src/libs/ReportUtils.ts

    Lines 10522 to 10526 in e029fad

    const oneTransactionThreadReportID = getOneTransactionThreadReportID(report, chatReport, currentReportActions);
    const oneTransactionThreadReport = deprecatedAllReports?.[`${ONYXKEYS.COLLECTION.REPORT}${oneTransactionThreadReportID}`];
    return isUnread(report, oneTransactionThreadReport, isReportArchived, derivedIsEmptyReport) && getReportNotificationPreference(report) !== CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE
    ? CONST.REPORT_IN_LHN_REASONS.IS_UNREAD
    : null;

    Why the guard exists, and why it is now only a stale proxy. It was added in Feb 2024 (617910c3b5a) so a chat whose only message was deleted would not stay bold, because lastVisibleActionCreated is not reset on delete. Look at what the delete path actually writes:

    const lastMessageText = getLastVisibleMessage(reportID, isReportArchived, optimisticReportActions).lastMessageText ?? '';
    const lastVisibleAction = ReportActionsUtils.getLastVisibleAction(reportID, canUserPerformWriteAction, optimisticReportActions);
    return {
    lastMessageText,
    lastVisibleActionCreated: lastVisibleAction?.created ?? '',
    lastActorAccountID: lastMessageText ? lastVisibleAction?.actorAccountID : CONST.DEFAULT_NUMBER_ID,
    };

    lastActorAccountID: lastMessageText ? lastVisibleAction?.actorAccountID : CONST.DEFAULT_NUMBER_ID,

    In the case the guard was written for, lastActorAccountID is falsy exactly when lastMessageText is empty. Since then isUnread() has gained an isEmptyReport() check at the very top. It reads lastMessageText first and then the last visible message:

    App/src/libs/ReportUtils.ts

    Lines 9815 to 9830 in e029fad

    /**
    * Check if the report is empty, meaning it has no visible messages (i.e. only a "created" report action).
    * No cache implementation which bypasses derived value check.
    */
    function generateIsEmptyReport(report: OnyxEntry<Report>, isReportArchived: boolean | undefined): boolean {
    if (!report) {
    return true;
    }
    if (report.lastMessageText) {
    return false;
    }
    const lastVisibleMessage = getLastVisibleMessage(report.reportID, isReportArchived);
    return !lastVisibleMessage.lastMessageText;
    }

    When a caller does not pass derivedIsEmptyReport, isEmptyReport() falls back to computing it (derivedIsEmptyReport ?? generateIsEmptyReport(...)), so every caller is covered:

    App/src/libs/ReportUtils.ts

    Lines 9729 to 9734 in e029fad

    function isEmptyReport(report: OnyxEntry<Report>, isReportArchived: boolean | undefined, derivedIsEmptyReport: boolean | undefined): boolean {
    if (!report) {
    return true;
    }
    return derivedIsEmptyReport ?? generateIsEmptyReport(report, isReportArchived);
    }

    So the deleted-message case is already answered inside isUnread(). The guard now matters only when a chat has a visible message but arrives without an actor. That is exactly this bug.

    Why my original useMarkAsRead theory was wrong: findLastAccessedReport falls back to the report with the newest lastReadTime. This chat has none, so it is never the auto-opened report (Concierge is), readNewestAction never runs for it and lastReadTime stays unset. That also explains why a full page reload does not change the result.

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

    Remove the !!report.lastActorAccountID guard from all three UI call sites so they use the same unread signal as the tab title counter:

    // SidebarUtils.getOptionData
    -    // When the only message of a report is deleted lastVisibleActionCreated is not reset leading to wrongly
    -    // setting it Unread so we add additional condition here to avoid empty chat LHN from being bold.
    -    result.isUnread = isUnread(report, oneTransactionThreadReport, isReportArchived, reportAttributes?.isEmpty) && !!report.lastActorAccountID;
    +    // Empty chats (e.g. the only message was deleted) are already excluded by isEmptyReport() inside isUnread().
    +    result.isUnread = isUnread(report, oneTransactionThreadReport, isReportArchived, reportAttributes?.isEmpty);
    // SidebarUtils.getIsUnreadReportForInboxTab
    -    // The `lastActorAccountID` guard matches getOptionData: ...
         return (
             isUnread(report, undefined, isReportArchived, derivedIsEmptyReport) &&
    -        !!report.lastActorAccountID &&
             getReportNotificationPreference(report) !== CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE
         );
    // OptionsListUtils (shouldUnreadBeBold)
    -            isOptionUnread = isUnread(report, oneTransactionThreadReport, option.private_isArchived, reportAttributesDerived?.[report.reportID]?.isEmpty) && !!report.lastActorAccountID;
    +            isOptionUnread = isUnread(report, oneTransactionThreadReport, option.private_isArchived, reportAttributesDerived?.[report.reportID]?.isEmpty);

    All three sites must change together. If only the LHN row changes, the row turns bold while the Unread tab still says "You're all caught up" and search still shows the chat as read.

    Regression safety:

    The backend could also send lastActorAccountID in OpenApp for this chat, since OpenReport does. That would be a nice-to-have, but the App should not depend on the field for read state. Other chats that arrive without it would hit the same bug.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    In tests/unit/SidebarUtilsTest.ts and tests/unit/OptionsListUtilsTest.tsx:

    1. A chat with no lastReadTime, lastActorAccountID: "" and a REPORTPREVIEW from another user (isEmpty: false). It is unread in getOptionData, it is included by getIsUnreadReportForInboxTab, and it is bold in the option list. These fail on main.
    2. A chat whose only non-CREATED action was deleted (lastMessageText: '', lastActorAccountID: 0, isEmpty: true). It stays read in all three places. This guards the original [$500] LHN - When you delete a message from a room, the conversation in the members remains bolded #36013 behavior.
    3. A chat where the last message is from the current user. It stays read.

    What alternative solutions did you explore? (Optional)

    • Keep the guard and add an exception (|| !!report.iouReportID, or fall back to the last visible action's actor). This fixes this repro, but it keeps a second, divergent source of truth for "has a real message" that isEmptyReport() already owns. It also leaves the bug for any non-IOU chat that arrives with a message but no actor.
    • Gate useMarkAsRead / delay the split navigator (my first version). Rejected, because this chat is never auto-opened and never marked read, so neither change has any effect.
  11. mukhrr commented on Sep 25, 2026

    @mukhrr
    Contributor

    Proposal

    What is the root cause of that problem?

    I reproduced this on dev web and the chat is not actually read. It only renders read.

    • Signed in as B in the same tab and opened the Inbox. The row for A's chat renders in regular weight, and the Unread tab says "No unread chats. You're all caught up."
    • In Onyx, B's copy of that chat (report_2827277120285184) has no lastReadTime at all, so nothing ever marked it read. Its actions are a CREATED and a REPORTPREVIEW from A (actorAccountID 23087835).
    • That chat carries lastActorAccountID: "", while the IOU report it previews carries "23087835". isUnread() returns true for it. The lastActorAccountID guard in getOptionData then turns the result back to false.
    • The report the split navigator auto-opened was Concierge (1736559253892187), and Concierge is also the only report the one-shot initial mark-as-read fired for. So the auto-mount path is not what makes A's chat look read.
    • A full page reload as B did not change anything. The row still rendered read and the Unread tab was still empty, so this is deterministic rather than a window during sign-in.

    Observed state on the chat while the bug was on screen:

      report_2827277120285184                              // B's copy of the chat with A
    + lastVisibleActionCreated: "2026-09-24 04:24:50.326"
    + reportActions: CREATED, REPORTPREVIEW (actor 23087835)
    + reportAttributes.isEmpty: false                      // so isUnread() -> true
    - lastReadTime: never set                              // B has read nothing
    - lastActorAccountID: ""                               // the guard reads this and forces isUnread -> false

    The guard sits in two places, which is why the bold row and the Unread tab both go quiet:

    result.statusNum = report.statusNum;
    // When the only message of a report is deleted lastVisibleActionCreated is not reset leading to wrongly
    // setting it Unread so we add additional condition here to avoid empty chat LHN from being bold.
    result.isUnread = isUnread(report, oneTransactionThreadReport, isReportArchived, reportAttributes?.isEmpty) && !!report.lastActorAccountID;

    function getIsUnreadReportForInboxTab(report: Report, isReportArchived: boolean, derivedIsEmptyReport: boolean | undefined): boolean {
    // The `lastActorAccountID` guard matches getOptionData: it keeps chats whose only visible message was
    // deleted out of the Unread tab even though isUnread() can still be true (lastVisibleActionCreated isn't reset).
    return (
    isUnread(report, undefined, isReportArchived, derivedIsEmptyReport) &&
    !!report.lastActorAccountID &&
    getReportNotificationPreference(report) !== CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE
    );
    }

    Its comment says it exists so a chat whose only message was deleted does not stay bold, because lastVisibleActionCreated is not reset on delete. That was a reasonable proxy when it landed in February 2024 (617910c). It is no longer needed. isUnread now takes derivedIsEmptyReport and gates on isEmptyReport before anything else:

    App/src/libs/ReportUtils.ts

    Lines 9833 to 9845 in e029fad

    function isUnread(report: OnyxEntry<Report>, oneTransactionThreadReport: OnyxEntry<Report>, isReportArchived: boolean | undefined, derivedIsEmptyReport: boolean | undefined): boolean {
    if (!report) {
    return false;
    }
    if (isEmptyReport(report, isReportArchived, derivedIsEmptyReport)) {
    return false;
    }
    if (!report.lastReadTime) {
    return true;
    }
    // lastVisibleActionCreated and lastReadTime are both datetime strings and can be compared directly

    generateIsEmptyReport is the purpose-built version of the same check. It falls through to getLastVisibleMessage, which resolves the action through getLastVisibleAction and its isReportActionVisibleAsLastAction filter, so a chat whose only message was deleted comes back empty and isUnread returns false on its own.

    App/src/libs/ReportUtils.ts

    Lines 9819 to 9830 in e029fad

    function generateIsEmptyReport(report: OnyxEntry<Report>, isReportArchived: boolean | undefined): boolean {
    if (!report) {
    return true;
    }
    if (report.lastMessageText) {
    return false;
    }
    const lastVisibleMessage = getLastVisibleMessage(report.reportID, isReportArchived);
    return !lastVisibleMessage.lastMessageText;
    }

    For B's chat with A the derived attribute is isEmpty: false, which is correct: the report preview is a real visible message. The stale proxy is the only thing suppressing the unread state.

    flowchart TD
        A["B's copy of the chat with A lands, no lastReadTime"] -->|"only visible action is a REPORTPREVIEW"| B["lastActorAccountID empty on the chat, 23087835 lives on the IOU report"]
        B --> C["isUnread() returns true, reportAttributes.isEmpty is false"]
        C -->|"lastActorAccountID guard reads empty"| D["getOptionData sets isUnread false, LHN row not bold"]
        C -->|"same guard in getIsUnreadReportForInboxTab"| E["Unread tab: No unread chats"]
    
    Loading

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

    Drop the lastActorAccountID guard at both sites and let isUnread do the emptiness check it already does. The two comments go with it, since the case they describe is now owned by isEmptyReport.

    -    // When the only message of a report is deleted lastVisibleActionCreated is not reset leading to wrongly
    -    // setting it Unread so we add additional condition here to avoid empty chat LHN from being bold.
    -    result.isUnread = isUnread(report, oneTransactionThreadReport, isReportArchived, reportAttributes?.isEmpty) && !!report.lastActorAccountID;
    +    result.isUnread = isUnread(report, oneTransactionThreadReport, isReportArchived, reportAttributes?.isEmpty);

    and the same removal in getIsUnreadReportForInboxTab, keeping the mute check.

    Both have to change together. Fixing only getOptionData would bold the row while the Unread tab still claimed there was nothing to read.

    With this applied I reloaded the same session and B's chat with A renders bold, and the Unread tab shows it with a count of 1. I added two regression tests to tests/unit/SidebarUtilsTest.ts, one on getOptionData and one on getReportsToDisplayInLHN, both using a never-read chat with isEmpty: false and no lastActorAccountID. They fail on current main and pass with the removal, and the other 108 tests in that file still pass.

    What alternative solutions did you explore? (Optional)

    Gating the initial mark-as-read on screen focus and window visibility, or making ReportsSplitNavigator wait for IS_LOADING_APP before pinning a fallback report. Neither applies here. I watched the split navigator pin Concierge, not A's chat, and readNewestAction ran once, for Concierge. A's chat never got a lastReadTime from any path, so delaying or suppressing the auto-mount leaves the LHN showing exactly what it shows today.

    Filling in the missing actor instead, for example falling back to the last visible action's actorAccountID when report.lastActorAccountID is empty. That fixes the symptom but keeps alive a guard that isEmptyReport already covers, and it adds an action lookup to a hot LHN path.

    I also considered whether this is a server-side gap, since lastActorAccountID sits empty in Onyx after OpenApp. It may well be. The App does not need it either way: the emptiness signal it relies on is derived locally and was already correct here.

  12. abbasifaizan70 commented on Sep 25, 2026

    @abbasifaizan70
    Contributor

    Proposal

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

    Account A sends a money request ("IOU") to an email that has no Expensify account yet, which creates a brand‑new pending account B. A signs out, and B signs in for the very first time (same browser tab, no other tab/window used). When B opens the Inbox, the DM with A — which B has never opened before — is already shown as read in the LHN, instead of unread.

    What is the root cause of that problem?

    isUnread() decides a report's read state in two steps: if the report has no lastReadTime it's unread, otherwise it compares lastReadTime to the last visible action's timestamp — unless the last action was written by the current user themselves, in which case it's treated as already read (so you don't see your own just‑sent message flagged unread):

    App/src/libs/ReportUtils.ts

    Lines 9842 to 9843 in e029fad

    if (!report.lastReadTime) {
    return true;

    App/src/libs/ReportUtils.ts

    Lines 9855 to 9860 in e029fad

    const drivingActorAccountID =
    (oneTransactionThreadReport?.lastVisibleActionCreated ?? '') > (report?.lastVisibleActionCreated ?? '') ? oneTransactionThreadReport?.lastActorAccountID : report?.lastActorAccountID;
    if (isUnreadFromTimestamp && drivingActorAccountID === deprecatedCurrentUserAccountID && !(lastReadTime < lastMentionedTime)) {
    return false;
    }

    The "self-authored" check compares drivingActorAccountID (the author of the report's last visible action) against a module‑level variable, deprecatedCurrentUserAccountID, instead of a value passed in as an argument. That variable is kept in sync with the logged-in user via an Onyx.connect on SESSION:

    App/src/libs/ReportUtils.ts

    Lines 1062 to 1075 in e029fad

    Onyx.connect({
    key: ONYXKEYS.SESSION,
    callback: (value) => {
    // When signed out, val is undefined
    if (!value) {
    return;
    }
    deprecatedCurrentUserEmail = value.email;
    deprecatedCurrentUserAccountID = value.accountID;
    deprecatedIsAnonymousUser = value.authTokenType === CONST.AUTH_TOKEN_TYPES.ANONYMOUS;
    deprecatedCurrentUserPrivateDomain = isEmailPublicDomain(deprecatedCurrentUserEmail ?? '') ? '' : Str.extractEmailDomain(deprecatedCurrentUserEmail ?? '');
    },
    });

    Notice the early return on line 1066-1068: // When signed out, val is undefined / if (!value) { return; }. When the session is cleared on sign‑out, this callback simply does nothing — it does not reset deprecatedCurrentUserAccountID back to undefined. Because sign‑out → sign‑in happens inside the same JS runtime (same tab), that variable keeps holding A's accountID all through the sign‑out and the start of B's sign‑in, until the new SESSION value (with B's accountID) is eventually merged into Onyx.

    Now trace what happens for the report with A once B's account data streams in: the report was created for B as part of the money-request flow, so its per‑participant lastReadTime is already a real (truthy) timestamp close to the report's creation time — it does not hit the !report.lastReadTime early return. The IOU action itself (the last visible action) was authored by A, so drivingActorAccountID === A. If the LHN row for this report evaluates isUnread() (via SidebarUtils.getOptionData → isUnread, called from

    result.isUnread = isUnread(report, oneTransactionThreadReport, isReportArchived, reportAttributes?.isEmpty) && !!report.lastActorAccountID;

    ) while deprecatedCurrentUserAccountID is still stale at A's ID, then drivingActorAccountID (A) === deprecatedCurrentUserAccountID (A) is true, and the "self‑authored" branch incorrectly fires — isUnread() returns false even though isUnreadFromTimestamp was true.

    This is a one‑shot mistake, but it sticks: the LHN row component that renders this conversation only subscribes to useOnyx for that specific report's own keys (REPORT_ACTIONS, REPORT_NAME_VALUE_PAIRS, transactions, etc.) — it has no useOnyx(ONYXKEYS.SESSION) subscription:
    https://github.com/Expensify/App/blob/e029fad955164435583153ee7f862942711273cb/src/components/LHNOptionsList/OptionRowLHN/OptionRowLHNData.tsx
    Since B never opens the conversation in this repro, none of the report's own Onyx keys change again afterward, so there is nothing to make that row recompute isUnread() once deprecatedCurrentUserAccountID finally catches up to B — the wrong "read" result is left standing in the LHN.

    This lines up exactly with the repro's "do not switch tabs/windows" constraint: a full page reload would re-initialize this module state cleanly from scratch, but a same‑tab sign‑out→sign‑in reuses the running JS module, so the previous user's leftover accountID can momentarily leak into the new user's first render.

    Other, equivalent SESSION listeners in this codebase avoid this exact trap by resetting to undefined/a default on sign‑out instead of returning early, e.g.:

    key: ONYXKEYS.SESSION,
    callback: (value: Session | undefined) => {
    currentUserAccountID = value?.accountID ?? CONST.DEFAULT_NUMBER_ID;
    currentUserLogin = value?.email ?? '';
    },
    });

    key: ONYXKEYS.SESSION,
    callback: (value) => {
    currentUserAccountID = value?.accountID;
    },
    });

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

    Fix the SESSION listener in ReportUtils.ts so it stops leaving stale user data behind on sign‑out, matching the pattern already used elsewhere in the codebase (optional‑chain into the new value instead of early‑returning on falsy):

    App/src/libs/ReportUtils.ts

    Lines 1062 to 1075 in e029fad

    Onyx.connect({
    key: ONYXKEYS.SESSION,
    callback: (value) => {
    // When signed out, val is undefined
    if (!value) {
    return;
    }
    deprecatedCurrentUserEmail = value.email;
    deprecatedCurrentUserAccountID = value.accountID;
    deprecatedIsAnonymousUser = value.authTokenType === CONST.AUTH_TOKEN_TYPES.ANONYMOUS;
    deprecatedCurrentUserPrivateDomain = isEmailPublicDomain(deprecatedCurrentUserEmail ?? '') ? '' : Str.extractEmailDomain(deprecatedCurrentUserEmail ?? '');
    },
    });

    Onyx.connect({
        key: ONYXKEYS.SESSION,
        callback: (value) => {
            deprecatedCurrentUserEmail = value?.email;
            deprecatedCurrentUserAccountID = value?.accountID;
            deprecatedIsAnonymousUser = value?.authTokenType === CONST.AUTH_TOKEN_TYPES.ANONYMOUS;
            deprecatedCurrentUserPrivateDomain = isEmailPublicDomain(deprecatedCurrentUserEmail ?? '') ? '' : Str.extractEmailDomain(deprecatedCurrentUserEmail ?? '');
        },
    });

    With this change, as soon as the session is cleared on sign‑out, deprecatedCurrentUserAccountID becomes undefined instead of staying pinned to the previous user's accountID. Even if the LHN evaluates isUnread() for B's reports before the new session finishes populating, drivingActorAccountID === deprecatedCurrentUserAccountID can never falsely match a leftover previous‑user ID (A === undefined is always false), so the "self‑authored" short‑circuit can no longer misfire across an account switch, and the conversation with A correctly renders as unread for B.

    This is a minimal, targeted fix: it doesn't touch the isUnread() decision logic itself, only removes the stale-state window that lets a previous session's identity leak into a new session's first render — the same safeguard this file's sibling SESSION listeners already have.

  13. 79 remaining items

  14. melvin-bot commented on Oct 26, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  15. ZhenjaHorbach commented on Oct 29, 2026

    @ZhenjaHorbach
    Contributor

    Contributor+ Checklist:

    • [Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

    It's more like a new requirements

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: N/A

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal

    Precondition:

    • Account A is an existing account.
    • Account B is an email address that does not have an Expensify account yet.

    Test:

    1. Sign in with account A.
    2. Create an expense and send it to account B's email address.
    3. Sign out of account A in the same tab.
    4. Sign in with account B.
    5. Go to Inbox.
    6. Verify that the chat with account A is shown in bold (unread) in the LHN.
    7. Open the Unread tab (filter).
    8. Verify that the chat with account A appears in the Unread tab.
    9. Open the search router and type account A's name or email.
    10. Verify that the chat with account A appears in bold in the search results.

    Do we agree 👍 or 👎

  16. ZhenjaHorbach commented on Oct 29, 2026

    @ZhenjaHorbach
    Contributor

    And there were no regressions here

  17. melvin-bot commented on Oct 29, 2026

    @melvin-bot

    @mallenexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  18. mallenexpensify commented on Oct 30, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @mukhrr due $250 via NewDot
    Contributor+: @ZhenjaHorbach due $250 via NewDot

  19. mukhrr commented on Oct 30, 2026

    @mukhrr
    Contributor

    Payment Summary

    Contributor: @mukhrr due $175 via NewDot
    Contributor+: @ZhenjaHorbach due $175 via NewDot

    @mallenexpensify I think this is due $250 thanks

  20. mallenexpensify commented on Oct 30, 2026

    @mallenexpensify
    Contributor

    @mukhrr you are correct! (not AI sending that, ha)
    Price updated cuz Help Wanted was added

  21. flaviadefaria commented on Nov 9, 2026

    @flaviadefaria
    Contributor

    Approved: @mukhrr due $250 via NewDot

  22. garrettmknight commented on Dec 1, 2026

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions