Skip to content

[$250] LHN - Expense report appears twice on LHN after opening chat. #91925

Closed

Description

@applause-bot

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: 9.3.84-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: #90113
Email or phone of affected tester (no customers): ibellicotest+2723@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Motorola MotoG60 / Android 12 (Hybrid app) - Windows 11 / Chrome
App Component: Left Hand Navigation (LHN)

Action Performed:

Prerequisite: Account has at least one workspace.

  1. Open the Expensify app.
  2. Create a manual expense and submit it to workspace.
  3. Open the just created expense and send a message in transaction thread.
  4. Return to "Inbox"
  5. Note that expense report is displayed only once.
  6. Open and close expense report from "Inbox"
  7. Note that report is still displayed once.
  8. Open workspace chat and return to "Inbox"
  9. Note that now, report is displayed twice.
  10. Open report one more time from "Inbox" and return.
  11. Note that report is now displayed once again.

Expected Result:

Expense report should only be visible once on "Inbox" and should not be duplicated when opened or when navigating to chat.

Actual Result:

Expense report is displayed twice on chats list on "Inbox" after opening chat.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7164908_1779932123179.Details.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Rizky Gunawan
Bug ID: 7164908

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

Activity

  1. added
    Bug
    on May 28, 2026
  2. applause-bot commented on May 28, 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/3d366a39e65f1ad22270961fd1ed2d8799b0ce0e3048b97a2434026bf54a2083

  3. MelvinBot commented on May 28, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The duplicate entry is a transaction thread appearing alongside its parent expense report in the LHN. These are two different reports with separate reportIDs, but they represent the same expense — so the user sees what looks like one report shown twice.

    The gate that should prevent this is isOneTransactionThread, which hides the transaction thread when the parent expense report has only one transaction. This check is called in two places: SidebarUtils.ts:313 and ReportUtils.ts:9590.

    Both checks read from a module-level allReportActions variable populated via Onyx.connect at ReportUtils.ts:1171-1181. The function looks up the parent (expense) report's actions at line 2611, and if those actions are missing or empty, getOneTransactionThreadReportAction returns undefined, so isOneTransactionThread returns false — and the transaction thread incorrectly passes the display filter.

    The trigger: when the user opens the workspace chat, the OpenReport API response includes report action updates (containing REPORT_PREVIEW with childReportID pointing to the expense report). The reportAttributes derived config detects this and triggers a re-evaluation of the expense report (and related transaction thread) in useSidebarOrderedReports. However, the module-level allReportActions variable may not have been updated yet when the re-render fires — creating a race where isOneTransactionThread reads stale data and fails to filter the transaction thread.

    Opening the expense report again fixes it because its OpenReport call re-loads the full report actions, restoring the module-level variable.

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

    Pass parentReportActions as a parameter to isOneTransactionThread instead of having it read from the module-level allReportActions. Both call sites in SidebarUtils.ts and ReportUtils.ts already have access to report actions data — either via Onyx hooks or via the same allReportActions collection at the call site. The fix is to thread the parent report's actions through as an argument so the function uses the same data the caller has, eliminating the stale-read race.

    Specifically:

    1. Add a parentReportActions parameter to isOneTransactionThread in ReportUtils.ts:2606 and use it at line 2611 instead of reading from the module-level variable.
    2. Update the call site in SidebarUtils.ts:313 to pass in the parent report's actions (the actions for the expense report, obtained from the same data source used by the sidebar evaluation).
    3. Update the call site in ReportUtils.ts:9590 to pass parentReportActions (already available at line 9573).

    What alternative solutions did you explore? (Optional)

    An alternative would be to ensure Onyx.connect module-level callbacks always fire before the derived value pipeline triggers React re-renders. However, this would require changes to the Onyx library's internal scheduling and is a much larger change with wider blast radius. Threading the data as a parameter is simpler and more robust.

    Possibly related issue

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  4. added
    External
    on May 28, 2026
  5. added
    Help Wanted
    on May 28, 2026
  6. yusufdeveloper2903 commented on May 28, 2026

    @yusufdeveloper2903
    Contributor

    Proposal

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

    On the Inbox (LHN), an expense report that contains a single transaction is shown twice after the user opens its workspace chat (without re-opening the expense report). Re-opening the expense report collapses it back to a single row, so the duplicate toggles on/off depending on which chat was last opened.

    What is the root cause of that problem?

    For a one-transaction expense report, the LHN hides the transaction thread so only the expense report row is shown. That hiding decision is made in shouldDisplayReportInLHN via isOneTransactionThread:

    src/libs/SidebarUtils.ts#L313-L315

    isOneTransactionThread resolves the thread ID from the parent expense report's report actions, which it reads from the module-level allReportActions cache:

    src/libs/ReportUtils.ts#L2606-L2616

    REPORT_ACTIONS is an evictable Onyx key:

    src/setup/index.ts#L37-L43

    So on a low-memory device (the report is on a Motorola MotoG60 / Android 12) the parent expense report's actions get purged once you navigate away from it. With no actions, getOneTransactionThreadReportAction hits its empty-list early-out and returns undefined:

    src/libs/ReportActionsUtils.ts#L1857-L1860

    getOneTransactionThreadReportID then returns undefined, so report.reportID === transactionThreadReportID is false and isOneTransactionThread returns false. The thread "fails open" and the LHN renders it next to its expense report — the report appears twice. Opening the expense report reloads its actions into the cache (thread hidden → one row); opening the workspace chat leaves them evicted (thread shown → two rows). The fix is not reactive either: reportsToDisplayInLHN doesn't depend on allReportActions, so the stale "show" decision sticks until the thread is re-evaluated.

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

    Make the hide decision resilient when the parent's actions are evicted, by falling back to the parent's reactive transactionCount (the same isOneTransactionReport signal the LHN already trusts on the REPORT collection, which is not evictable). Behavior when actions are loaded is unchanged.

    src/libs/ReportUtils.ts — isOneTransactionThread:

         if (!report || !parentReport) {
             return false;
         }
    
    -    const parentReportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReport?.reportID}`] ?? ([] as ReportAction[]);
    +    const parentReportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReport?.reportID}`];
    +
    +    // REPORT_ACTIONS is an evictable Onyx key, so the parent expense report's actions can be purged on
    +    // low-memory devices once we navigate away. Without them getOneTransactionThreadReportID() returns
    +    // undefined and the thread "fails open", duplicating the one-transaction report in the LHN. Fall back
    +    // to the parent's reactive transactionCount so the thread stays collapsed until its actions reload.
    +    if (isEmptyObject(parentReportActions)) {
    +        return isOneTransactionReport(parentReport) && !!report.parentReportActionID && !isSentMoneyReportAction(threadParentReportAction);
    +    }
    
         const chatReport = deprecatedAllReports?.[`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.chatReportID}`];
         const transactionThreadReportID = getOneTransactionThreadReportID(parentReport, chatReport, parentReportActions, isOffline);
         return report?.reportID === transactionThreadReportID && !isSentMoneyReportAction(threadParentReportAction);
    • isOneTransactionReport(parentReport) is parentReport.transactionCount === 1 and transactionCount only exists on IOU/Expense/Invoice reports, so the fallback can only collapse a thread under a genuine one-transaction expense report.
    • !!report.parentReportActionID confirms report is actually a thread, so non-thread reports are never affected.
    • isEmptyObject and isOneTransactionReport are already in ReportUtils.ts; no new imports.
    • Files: src/libs/ReportUtils.ts only. No change to SidebarUtils, the LHN hook, or the eviction config. The other isOneTransactionThread call sites (report header, etc.) only become more correct when actions are evicted.

    Test plan: create a manual expense, submit to a workspace, send a message in its transaction thread, return to Inbox (one row), open the workspace chat, return to Inbox → the expense report must still appear once.

    What alternative solutions did you explore? (Optional)

    1. Add allReportActions as a dependency of reportsToDisplayInLHN so the LHN recomputes when the parent's actions reload — rejected: REPORT_ACTIONS is a large, high-churn collection and recomputing the LHN on every action change defeats the incremental cache built specifically to keep the LHN fast on low-end devices.
    2. Remove REPORT_ACTIONS from evictableKeys (src/setup/index.ts) — rejected: eviction is the deliberate memory-management strategy for exactly the low-RAM devices where this reproduces; keeping every report's actions resident risks OOM.
    3. Prefetch/keep the parent expense report's actions whenever its thread is in the LHN — rejected as over-engineering: it adds fetch traffic and still races with eviction instead of removing the dependency.
  7. MobileMage commented on May 28, 2026

    @MobileMage
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-05-28 06:34:22 UTC.

    Proposal

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

    After creating a one-transaction expense report, commenting in its transaction thread, returning to the Inbox, then opening the workspace chat and returning to the Inbox again, the expense report is rendered twice in the LHN. The duplicate goes away after re-opening the expense report once more. The same report (display name) appears as two distinct rows because both the expense report and the transaction thread underneath it end up in the LHN list, when only the expense report should be there.

    What is the root cause of that problem?

    The LHN filters out the single-transaction thread row using isOneTransactionThread so that only the parent expense report row is shown. That filter is the very first early-bail inside shouldDisplayReportInLHN:

    if (isOneTransactionThread(report, parentReport, parentReportAction, isOffline)) {
    return {shouldDisplay: false};
    }

    isOneTransactionThread(report, parentReport, parentReportAction, isOffline) does not decide the answer from properties of report and parentReport alone. It reaches into the module-level allReportActions cache and recomputes the parent's oneTransactionThreadReportID from scratch every call:

    App/src/libs/ReportUtils.ts

    Lines 2606 to 2616 in 377d37b

    function isOneTransactionThread(report: OnyxEntry<Report>, parentReport: OnyxEntry<Report>, threadParentReportAction: OnyxEntry<ReportAction>, isOffline?: boolean) {
    if (!report || !parentReport) {
    return false;
    }
    const parentReportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReport?.reportID}`] ?? ([] as ReportAction[]);
    const chatReport = deprecatedAllReports?.[`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.chatReportID}`];
    const transactionThreadReportID = getOneTransactionThreadReportID(parentReport, chatReport, parentReportActions, isOffline);
    return report?.reportID === transactionThreadReportID && !isSentMoneyReportAction(threadParentReportAction);
    }

    getOneTransactionThreadReportID then walks parentReport's report actions, counts IOU report actions, and returns childReportID only when exactly one non-deleted IOU.CREATE/SPLIT/TRACK action is found. If the parent's actions are not in the cache (empty fallback at line 2611), or the cache momentarily contains the IOU action without its childReportID, or the count is off by one because of an in-flight Onyx merge, the function returns undefined and isOneTransactionThread returns false, which means the transaction thread is treated as a normal chat thread and added to displayedReports.

    Step 8 is what trips it. Opening the workspace chat issues openReport(workspaceChat), whose response triggers Onyx writes for REPORT_ACTIONS_${workspaceChat} and a refresh of the workspace policy. Both feed getUpdatedReports() in useSidebarOrderedReports:

    if (policiesUpdates) {
    const updatedPolicies = new Set(Object.keys(policiesUpdates).map((policyKey) => policyKey.replace(ONYXKEYS.COLLECTION.POLICY, '')));
    for (const key of Object.entries(chatReports ?? {})
    .filter(([, value]) => {
    if (!value?.policyID) {
    return;
    }
    return updatedPolicies.has(value.policyID);
    })
    .map(([reportKey]) => reportKey)) {
    reportsToUpdate.add(key);
    }
    }

    The policies-updates branch sweeps every report whose policyID matches the touched policy — this is the workspace policy, so the workspace chat, the expense report, and the transaction thread (which inherits policyID from its grandparent) all get pushed into reportsToUpdate. SidebarUtils.updateReportsToDisplayInLHN then re-runs shouldDisplayReportInLHN on the transaction thread. During that re-eval the parent's REPORT_ACTIONS collection is in the middle of being replaced by the OpenReport successData, so allReportActions[REPORT_ACTIONS_${expenseReport}] either misses the IOU action or has it without childReportID for a tick. isOneTransactionThread returns false, the early-bail at SidebarUtils:313 is skipped, the thread passes shouldReportBeInOptionList (it's an unread money-request thread), and the thread row is added to displayedReports. The incremental cache never reconciles it on the way back to Inbox in step 9 because nothing forces a re-check of the thread until step 10's fetchReport(expenseReport) rewrites the parent's actions cleanly and the next sweep deletes the stale entry.

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

    Make the LHN's filter for the one-transaction thread robust against transient REPORT_ACTIONS cache states by short-circuiting on stable properties that live on the reports themselves. Inside shouldDisplayReportInLHN, before (or in addition to) calling isOneTransactionThread, treat report as a one-transaction thread when all three of these hold: parentReport?.transactionCount === 1, report.parentReportID === parentReport?.reportID, and isReportTransactionThread(report) (i.e. isMoneyRequest(report) || isTrackExpenseReport(report)). transactionCount and parentReportID are written to the report object itself in MoneyRequestBuilder/Split/TrackExpense and survive successData merges atomically, so this condition is not racy. If it matches, return {shouldDisplay: false} immediately, the same outcome as the existing branch.

    // Get report metadata and status
    const parentReportAction = getReportAction(report?.parentReportID, report?.parentReportActionID);
    const doesReportHaveViolations = !!getViolatingReportIDForRBRInLHN(report, transactionViolations);
    const isHidden = isHiddenForCurrentUser(report);
    const isFocused = report.reportID === currentReportId;
    const chatReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`];
    const parentReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`];
    const hasErrorsOtherThanFailedReceipt = hasReportErrorsOtherThanFailedReceipt(report, chatReport, doesReportHaveViolations, transactionViolations, transactions, reportAttributes);
    const isReportInAccessible = report?.errorFields?.notFound;
    if (isOneTransactionThread(report, parentReport, parentReportAction, isOffline)) {
    return {shouldDisplay: false};
    }

    This is intentionally a local fix in SidebarUtils.shouldDisplayReportInLHN rather than a change to isOneTransactionThread itself, because the latter is also used by getDisplayedReportID, HeaderView and UpdateMoneyRequest, where the existing report-actions-based check is the source of truth (e.g. once a second expense is added, transactionCount rises before the new IOU action lands, and callers need the strict count of IOU actions to behave correctly). Scoping the guard to the LHN filter keeps the well-tested behaviour everywhere else while closing the dedup hole that only matters when deciding whether the thread row should be rendered alongside the expense report row.

    What alternative solutions did you explore? (Optional)

    Forcing the transaction thread into getUpdatedReports's key set whenever the parent expense report's REPORT_ACTIONS update arrives (so the incremental sweep always re-checks the thread on the next tick once the actions cache is consistent) — rejected because it just narrows the race window instead of closing it, and still relies on allReportActions being settled before updateReportsToDisplayInLHN runs, which is exactly what is not guaranteed during the OpenReport response merge.

  8. neerajbachani commented on May 28, 2026

    @neerajbachani
    Contributor

    Proposal

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

    On LHN/Inbox, a submitted one-transaction expense report intermittently appears twice after opening workspace chat. The duplicate is the transaction-thread report being shown alongside its parent expense report.

    What is the root cause of that problem?

    isOneTransactionThread() was too strict in how it identified collapsible one-transaction threads during intermediate Onyx merge states. In those states, linkage can be unresolved (undefined/FAKE_REPORT_ID) or temporarily mismatched, so the function returned false and allowed the thread row to render.

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

    Harden isOneTransactionThread() in src/libs/ReportUtils.ts to collapse one-transaction thread rows even when linkage is transiently incomplete or mismatched.

    • Relax thread-candidate guard (do not require parentReportActionID).
    // before
    const isTransactionThreadCandidate = isOneTransactionReport(parentReport) && isReportTransactionThread(report) && !!report.parentReportActionID;
    
    // after
    const isTransactionThreadCandidate = isOneTransactionReport(parentReport) && isReportTransactionThread(report);
    • Keep unresolved-ID fallback (undefined or FAKE_REPORT_ID).
    if ((!transactionThreadReportID || transactionThreadReportID === CONST.FAKE_REPORT_ID) && isTransactionThreadCandidate && !isSentMoneyParentAction) {
        return true;
    }
    • Add mismatch fallback (stale linkage points to a different child ID).
    if (isTransactionThreadCandidate && !isSentMoneyParentAction && transactionThreadReportID !== report.reportID) {
        return true;
    }
    • Preserve sent-money exemption behavior as-is.

    Why this fix is correct

    It enforces the intended UX rule directly: for a one-transaction expense parent, the transaction thread should not be shown as a separate LHN row, even when action linkage is temporarily stale.

    What alternative solutions did you explore? (Optional)

    • Set-based dedupe in LHN sorting (rejected: symptom masking, not root-cause fix).
    • Onyx scheduling/order changes (rejected: high blast radius).
    • Disabling REPORT_ACTIONS eviction (rejected: memory tradeoff, still not the core logic fix)
  9. David-2002065 commented on May 28, 2026

    @David-2002065
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-05-28 06:32:45 UTC.

    Proposal

    What is the root cause of that problem?

    The LHN keeps an incremental cache (currentReportsToDisplay) and only re-evaluates the entries whose Onyx keys appear in updatedReportsKeys. The check that hides a one‑transaction child thread from the LHN (shouldDisplayReportInLHN) depends on its parent expense report and on the parent's reportActions:

    if (isOneTransactionThread(report, parentReport, parentReportAction, isOffline)) {
        return {shouldDisplay: false};
    }

    isOneTransactionThread resolves the IOU childReportID from the parent's actions (ReportUtils.ts#L2595-L2605) — so the filter result for the child thread is purely a function of the parent's state.

    In getUpdatedReports we propagate updates from transactions, violations, drafts, policies, RNVPs and the prev/current report. We never propagate an update of an expense report (or its actions) back to its transaction-thread child:

    https://github.com/Expensify/App/blob/main/src/hooks/useSidebarOrderedReports.tsx#L118-L138

    So when opening the workspace chat triggers OpenReport and the response updates the expense report (e.g., lastVisibleActionCreated, lastReadTime, transactionCount, an IOU action becoming temporarily detached), the parent is re-evaluated through updateReportsToDisplayInLHN but the child transaction thread is not — its previous "hidden" decision in the cache flips to "visible" only when its own key happens to come through (e.g., later, when the user opens the expense report and the prev/current diff covers it via the parent's IOU action's childReportID). Result: the LHN renders both the parent expense report row and its one‑transaction child row, which look identical to the user → "report displayed twice". Opening the report restores the invariant on the next cycle → "displayed once again".

    This was exposed by PR #90113 which changed the report-navigation flow (prevDerivedCurrentReportID/derivedCurrentReportID transitions now move through different dynamic routes), so the prev/current pair that previously incidentally covered the child no longer does after the workspace-chat visit.

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

    Treat the LHN visibility of a transaction-thread child as dependent on its parent and invalidate it whenever the parent (or the parent's report actions) is updated. The smallest, contained fix is in getUpdatedReports — when an updated report has a child transaction thread, queue the child as well:

         if (reportUpdates) {
             for (const key of Object.keys(reportUpdates ?? {})) {
                 reportsToUpdate.add(key);
    +            // A one-transaction child thread's LHN visibility is computed from its parent,
    +            // so re-evaluate it whenever the parent expense/IOU report changes.
    +            const parent = chatReports?.[key];
    +            const childThreadID = reportAttributes?.[parent?.reportID ?? '']?.oneTransactionThreadReportID;
    +            if (childThreadID && childThreadID !== CONST.FAKE_REPORT_ID) {
    +                reportsToUpdate.add(`${ONYXKEYS.COLLECTION.REPORT}${childThreadID}`);
    +            }
             }
         }

    We already compute oneTransactionThreadReportID per report in reportAttributes, so this is an O(1) lookup. The same propagation should be added in the reportActionsUpdates path (and ideally in the transactionsUpdates branch in useSidebarOrderedReports.tsx#L128-L138, which currently picks either the parent or the child — it should propagate to both whenever the parent is one-transaction so the cached child entry is never stale).

    As a defensive belt-and-suspenders, I'd also wrap the output of combineReportCategories in a Set so an upstream regression can never render two rows for the same reportID:

     ): string[] {
         const result: string[] = [];
    +    const seen = new Set<string>();
         const groups = [pinnedAndGBRReports, errorReports, draftReports, nonArchivedReports, archivedReports];
         for (const group of groups) {
             for (const report of group) {
    -            if (report?.reportID) {
    +            if (report?.reportID && !seen.has(report.reportID)) {
    +                seen.add(report.reportID);
                     result.push(report.reportID);
                 }
             }
         }
         return result;
     }

    I'd also add a Jest test in tests/unit/SidebarOrderTest.ts that mounts a one-transaction expense report, simulates the OpenReport flow on the workspace chat (a partial Onyx merge of lastVisibleActionCreated/lastReadTime on the parent), and asserts orderedReportIDs has exactly one entry for the expense.

    What alternative solutions did you explore? (Optional)

    1. Re-evaluate the entire cache whenever the current report changes — i.e., set effectiveUpdatedReports = Object.keys(currentReportsToDisplay) on every derivedCurrentReportID transition. This would mask the bug but defeats the whole point of the incremental update path added for LHN perf and would re-introduce the FPS regression that motivated currentReportsToDisplay in the first place.

    2. Drop the cache and always call getReportsToDisplayInLHN from scratch — same downside as (1), worse on large accounts (the bug reporter is on a workspace, but other users have thousands of reports). Rejected.

    3. Fix only inside shouldDisplayReportInLHN — e.g., short-circuit on parentReport?.transactionCount === 1. This skips the isOneTransactionThread check correctly but doesn't address the cache-staleness root cause: any other field on a one-transaction child (errors, drafts) could still be wrong because the row isn't re-evaluated when the parent changes. The proposed fix targets the actual invariant: "the child's display depends on the parent, so the child must be invalidated with the parent."

  10. melvin-bot commented on May 28, 2026

    @melvin-bot

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

  11. aswin-s commented on May 28, 2026

    @aswin-s
    Contributor

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  12. wildan-m commented on May 28, 2026

    @wildan-m
    Contributor

    Proposal

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

    When a one-transaction expense report is opened from the inbox, then the user navigates to the parent workspace chat and back to the inbox, the same expense report row appears twice in the LHN. Opening the report again from the LHN restores it to a single row.

    What is the root cause of that problem?

    The LHN list of displayed reports is maintained by an incremental cache in useSidebarOrderedReports. After the first full pass, subsequent updates only re-evaluate reports whose Onyx keys are listed in updatedReportsKeys:

    function updateReportsToDisplayInLHN({
    displayedReports,
    reports,
    updatedReportsKeys,
    currentReportId,
    isInFocusMode,
    betas,
    transactionViolations,
    reportNameValuePairs,
    reportAttributes,
    draftComments,
    transactions,
    isOffline,
    currentUserLogin,
    currentUserAccountID,
    }: UpdateReportsToDisplayInLHNProps) {
    // Use a lazy copy to avoid creating a new object reference when no entries actually change.
    let displayedReportsCopy: ReportsToDisplayInLHN | undefined;
    const getMutableCopy = (): ReportsToDisplayInLHN => {
    if (!displayedReportsCopy) {
    displayedReportsCopy = {...displayedReports};
    }
    return displayedReportsCopy;
    };
    for (const reportID of updatedReportsKeys) {
    const report = reports?.[reportID];
    if (!report) {
    if (reportID in displayedReports) {
    delete getMutableCopy()[reportID];
    }
    continue;
    }
    // Get the specific draft comment for this report instead of using a single draft comment for all reports
    // This fixes the issue where the current report's draft comment was incorrectly used to filter all reports
    const reportDraftComment = draftComments?.[`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${report.reportID}`];
    const {shouldDisplay, hasErrorsOtherThanFailedReceipt} = shouldDisplayReportInLHN({
    report,
    reports,
    currentReportId,
    isInFocusMode,
    betas,
    transactionViolations,
    draftComment: reportDraftComment,
    transactions,
    isOffline,
    isReportArchived: isArchivedReport(reportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.reportID}`] ?? {}),
    reportAttributes,
    currentUserLogin,
    currentUserAccountID,
    });
    if (shouldDisplay) {
    const requiresAttention = reportAttributes?.[report?.reportID]?.requiresAttention ?? false;
    const hasAttentionOrError = requiresAttention || hasErrorsOtherThanFailedReceipt;
    const existingEntry = displayedReports[reportID];
    if (hasAttentionOrError) {
    if (
    existingEntry !== report ||
    existingEntry?.requiresAttention !== requiresAttention ||
    existingEntry?.hasErrorsOtherThanFailedReceipt !== hasErrorsOtherThanFailedReceipt
    ) {
    getMutableCopy()[reportID] = {...report, requiresAttention, hasErrorsOtherThanFailedReceipt};
    }
    } else if (existingEntry !== report) {
    getMutableCopy()[reportID] = report;
    }
    } else if (reportID in displayedReports) {
    delete getMutableCopy()[reportID];
    }
    }
    return displayedReportsCopy ?? displayedReports;

    Visibility of a transaction thread is mutually exclusive with its parent expense report — the thread is hidden by the isOneTransactionThread early return in shouldDisplayReportInLHN:

    if (isOneTransactionThread(report, parentReport, parentReportAction, isOffline)) {
    return {shouldDisplay: false};
    }

    isOneTransactionThread decides this by reading the parent expense report's actions from the module-level allReportActions cache in ReportUtils.ts and looking for the IOU action whose childReportID points back to the thread:

    App/src/libs/ReportUtils.ts

    Lines 2606 to 2616 in 377d37b

    function isOneTransactionThread(report: OnyxEntry<Report>, parentReport: OnyxEntry<Report>, threadParentReportAction: OnyxEntry<ReportAction>, isOffline?: boolean) {
    if (!report || !parentReport) {
    return false;
    }
    const parentReportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReport?.reportID}`] ?? ([] as ReportAction[]);
    const chatReport = deprecatedAllReports?.[`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.chatReportID}`];
    const transactionThreadReportID = getOneTransactionThreadReportID(parentReport, chatReport, parentReportActions, isOffline);
    return report?.reportID === transactionThreadReportID && !isSentMoneyReportAction(threadParentReportAction);
    }

    The mutual exclusion is therefore only enforced at the moment a transaction thread's own key is being re-evaluated. The cache in useSidebarOrderedReports.getUpdatedReports never adds the transaction thread's key just because its expense parent updated. Concretely, on a transactions Onyx update the hook deliberately picks the expense report key when the parent is a one-transaction report and otherwise picks the thread key — never both:

    if (transactionsUpdates) {
    // We need to select the report linked to a transaction, to properly recalculate getReceiptUploadErrorReason, which is the expense report if it is isOneTransactionReport
    // or the transaction thread report if it is otherwise.
    for (const key of Object.values(transactionsUpdates ?? {}).map((transaction) =>
    transaction?.reportID && isOneTransactionReport(chatReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transaction.reportID}`])
    ? `${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID}`
    : `${ONYXKEYS.COLLECTION.REPORT}${getTransactionThreadReportID(transaction)}`,
    )) {
    reportsToUpdate.add(key);
    }
    }

    When the user opens the workspace chat in step 8, openReport triggers a fresh fetch that reorders/refreshes the expense report and its IOU action. There is a brief window where the thread's REPORT key fires an update before the IOU action's childReportID linking it back to the thread has been written to allReportActions. During that window, isOneTransactionThread returns false (no IOU action with the matching childReportID is found, so getOneTransactionThreadReportID returns undefined), shouldDisplayReportInLHN returns true, and the thread is added to the cached displayedReports. From that point on the thread's key never reappears in updatedReportsKeys — only the expense report's key does — so the cache keeps both entries, producing the duplicated LHN row. Opening the expense report from the LHN forces the thread back through updatedReportsKeys (it is added via the prevDerivedCurrentReportID/derivedCurrentReportID branch) and the cache repairs itself.

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

    Enforce the expense-report/transaction-thread mutual exclusion inside the incremental updater itself, instead of relying on the thread's key happening to be in updatedReportsKeys at the right moment.

    In updateReportsToDisplayInLHN (src/libs/SidebarUtils.ts), whenever the updater confirms that a one-transaction expense report should remain displayed, also drop that report's transaction thread from the displayed map if it is present. The thread id is already available via the reportAttributes derived value (oneTransactionThreadReportID) that the updater already receives, so no extra Onyx reads are needed.

    The parent expense report's REPORT key reliably appears in updatedReportsKeys after the race window closes — both because openReport writes the expense report itself, and because the subsequent IOU transaction update routes the parent key into updatedReportsKeys via getUpdatedReports (the transactionsUpdates branch maps to the expense report key when the parent is a one-transaction report). So this single-sided enforcement is enough to make the LHN cache self-correct regardless of the order in which the transaction thread, the expense report, and the IOU action arrive from Onyx — the displayed map can never end up holding both the parent expense report and its single-transaction child thread at the same time.

    Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/91925-lhn-duplicate-expense-row?expand=1

    What alternative solutions did you explore? (Optional)

    Forcing a full rebuild of reportsToDisplayInLHN on every workspace-chat open by clearing the cache would also resolve the duplication, but it would discard the performance benefit of the incremental updater for a problem that only affects expense/thread pairs — the targeted invariant fix above is cheaper and avoids regressing LHN render time for unrelated navigations.

  13. 23 remaining items

  14. hungvu193 commented on Jun 10, 2026

    @hungvu193
    Contributor

    Internal issue

  15. self-assigned this
    on Jun 10, 2026
  16. removed
    Help Wanted
    on Jun 10, 2026
  17. melvin-bot commented on Jun 11, 2026

    @melvin-bot

    @hungvu193 @c3024 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

  18. hungvu193 commented on Jun 12, 2026

    @hungvu193
    Contributor

    Linked PR is merged. Going to unassign myself to clean up my list.

  19. removed their assignment
    on Jun 12, 2026
  20. melvin-bot commented on Jun 15, 2026

    @melvin-bot

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

  21. c3024 commented on Jun 16, 2026

    @c3024
    Contributor

    PR on production. Requested QA for a retest.

  22. m-natarajan commented on Jun 16, 2026

    @m-natarajan

    Issue is not reproducible on Windows 11/ Chrome and Samsung S23FE/ Android 16 in v9.4.8-2

    91925-Web.mp4
    91925-A16.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions