Skip to content

[Due for payment 2026-09-09] [$250] Existing expenses get highlighted when opening a report #98308

Closed

Description

@izarutskaya

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.52-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:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @FitseTLT
Slack conversation (hyperlinked to channel name): #expensify_bugs

Action Performed:

Prerequisites: User has multiple expense reports in different workspace chats

  1. Go to https://staging.new.expensify.com/
  2. Navigate to Inbox
  3. Switch chats one by one to check expense reports

Expected Result:

Existing expenses get highlighted when opening a report.

Actual Result:

Existing expenses are not highlighted when opening a report.

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

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

Screenshots/Videos

Recording.3932.mp4

View all open jobs on GitHub

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

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 11, 2026
  2. MelvinBot commented on Aug 11, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The highlight-on-open animation is driven entirely by a "rail" of transaction IDs (REPORT_METADATA.pendingNewTransactionIDs) that gets written at expense-creation time, not at report-open time. When you open a report, useNewTransactions deliberately skips its render-diff path on the first mount (skipFirstTransactionsChange), so on a fresh open the rail is the only thing that can highlight any row.

    That rail is only written under a narrow gate in MoneyRequestBuilder.ts:696-698:

    !isSelfDMSplit && !shouldSkipReportHighlightRail && addMakesReportMultiTransaction
    

    So a transaction is never flagged for highlight when it is the first/only expense in the report (addMakesReportMultiTransaction requires the report to already contain another non-deleted transaction, i.e. the 0→1 add is excluded), or when the creating flow passes shouldSkipReportHighlightRail. Any expense not on the rail shows no highlight when its report is opened — which matches "existing expenses are not highlighted when opening a report."

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

    Decide the intended scope of the highlight and adjust the write-side gate accordingly:

    • If single-expense reports should highlight on open, relax the addMakesReportMultiTransaction condition so the first (0→1) transaction is also flagged onto the rail.
    • Audit which creation flows pass shouldSkipReportHighlightRail (added recently by #97520) and confirm none of them actually do land on a report the user then opens.
    Investigation details, evidence & the wording contradiction

    Read side is correctly wired — MoneyRequestReportActionsList.tsx:157-160 reads pendingNewTransactionIDs and passes all args to useNewTransactions. The rows consume the result through useAnimatedHighlightStyle. When no highlight appears, the rail was never written — so the bug is on the write side.

    Temporally-closest changes (issue reported at v9.4.52-0 ~2026-08-11):

    • #97520 "Fix stale split highlights when splitting from the Spend page" — merged 2026-08-07 (4 days before). Added the shouldSkipReportHighlightRail param to the same write condition. Strongest recent-regression suspect.
    • #94670 "Highlight animation is visible on added expense after duplication" — merged 2026-07-13. Introduced the addMakesReportMultiTransaction gate that excludes the first/only transaction.

    ⚠️ The issue wording is internally contradictory — the title says existing expenses get highlighted (i.e. shouldn't), while Expected/Actual say they should be highlighted but aren't. These point at opposite fixes:

    • If the real complaint is "newly-added / first expenses should flash on open but don't" → the rail gate above is the root cause (this proposal).
    • If the real complaint is "existing/old expenses are wrongly flashing on open" → look instead at the rail not being cleared, or prevTransactions resetting to undefined on a remount so the next length increase is misread as new.

    Testing note: I couldn't reproduce live — the test session failed to render the app (infra issue), so this is code-evidence-based (Medium confidence). A quick confirmation of whether the affected reports are single-expense (0→1, directly explained by addMakesReportMultiTransaction) or multi-expense would firm this up.

    Related issues


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/98308) to create a draft PR.
    To refine: @MelvinBot <your feedback> — in particular, please confirm which behavior is expected (highlight the first/only expense on open, vs. stop existing expenses from flashing).
    To reject: Explain why you are rejecting Melvin's proposal.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Aug 11, 2026
  4. melvin-bot commented on Aug 11, 2026

    @melvin-bot

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

  5. melvin-bot commented on Aug 11, 2026

    @melvin-bot
  6. huult commented on Aug 12, 2026

    @huult
    Contributor

    @FitseTLT (original reporter) could you clarify: when you say "existing expenses get highlighted," do you mean:

    1. Expenses that were recently added (by you or someone else) and you're seeing the report for the first time since, should flash so you notice them, or
    2. Something else entirely (e.g. a specific expense you were sent to via link should be visibly indicated)?
  7. FitseTLT commented on Aug 12, 2026

    @FitseTLT
    Contributor

    @FitseTLT (original reporter) could you clarify: when you say "existing expenses get highlighted," do you mean:

    1. Expenses that were recently added (by you or someone else) and you're seeing the report for the first time since, should flash so you notice them, or
    2. Something else entirely (e.g. a specific expense you were sent to via link should be visibly indicated)?

    Not only as original reporter but also as original developer of the feature the intention was to show where new expense you created were added by scrolling and highlighting the expense on the report preview but now on this issue I see old expenses being highlighted.

  8. huult commented on Aug 13, 2026

    @huult
    Contributor

    @FitseTLT Ah, could you mention the PR where you implemented this feature? thank you 😄

  9. FitseTLT commented on Aug 13, 2026

    @FitseTLT
    Contributor
  10. skrohan5016-coder commented on Aug 14, 2026

    @skrohan5016-coder

    Proposal

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

    Only a genuinely newly added expense should scroll into view and highlight, and it should happen once. An expense that was already highlighted must not flash again later merely because the user reopens the report or the report regains navigation focus.

    The reporter’s clarification is important here: the original feature was built to highlight the new expense the user just created, but the current defect is that old expenses are being highlighted. So the earlier interpretation that every existing expense should highlight on report open is inverted.

    What is the root cause of that problem?

    The stale highlight comes from a mismatch between actual report-table visibility and navigation focus when consuming REPORT_METADATA.pendingNewTransactionIDs.

    1. Money-request creation records the new transaction ID in pendingNewTransactionIDs. useNewTransactions() treats every still-truthy ID on that rail as new, including on a fresh mount where a render-to-render diff cannot help.
    2. MoneyRequestReportActionsList correctly defines whether the table is visible as:
      • narrow layout: visible only while the report route is focused;
      • wide layout: visible even when another RHP is stacked above it.
    3. The transaction list receives this real isReportVisible value, so on wide layout it is allowed to show the highlight in the background while the transaction-detail RHP is still open. That behavior is intentional and is explicitly covered by PR fix: Reports - Highlight animation is visible on added expense after duplication #94670.
    4. However, useNewTransactions() is passed the raw isFocused value instead. Its cleanup effect refuses to delete the pending ID whenever isFocused === false.
    5. Therefore, on wide layout the row can be visibly highlighted while the report route is not focused, but the rail entry is not consumed. The persisted ID survives. When the report later remounts or is reopened, the same already-seen transaction is read from the rail again and is incorrectly treated as new.

    In other words, one layer says “the highlight was visible and delivered,” while the lifecycle layer says “the report was not focused, so keep the highlight for later.” That disagreement is what converts a new expense into an old expense that repeatedly flashes.

    Relevant code:

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

    1. Change the final useNewTransactions() argument from navigation-specific isFocused semantics to actual visibility/consumption semantics, preferably renaming it to isReportVisible or shouldConsumePendingHighlights.
    2. Pass the already-computed isReportVisible value from MoneyRequestReportActionsList into the hook.
    3. Clear only the truthy pending IDs whose transactions were actually resolved into newTransactions, and only after the table was visible and had the opportunity to scroll/highlight them.
    4. Preserve the intended narrow-layout behavior: while a transaction RHP fully covers the report, keep the rail; when the RHP closes and the table becomes visible, highlight once and then clear it.
    5. Do not relax the write-side gate to mark every existing transaction as new. The reporter clarification confirms that old rows should not be highlighted just because a report opens.

    This is a small semantic alignment: the same visibility decision must control both rendering the animation and acknowledging that it was delivered.

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

    1. Wide layout + stacked RHP: the report table is visible but its route is not focused; a new transaction highlights immediately, its pending ID is cleared, and reopening the report does not highlight it again.
    2. Narrow layout + stacked RHP: the table is covered; the pending ID remains until the RHP closes, then highlights exactly once and is cleared.
    3. Fresh remount after consumption: a tombstoned/cleared rail never produces an old highlight.
    4. Consecutive additions: multiple truthy IDs are consumed without re-highlighting an earlier transaction while a newer one is added.
    5. Diff-only/Pusher additions: transactions detected by the normal render diff still behave exactly as before and do not depend on the metadata rail.

    What alternative solutions did you explore? (Optional)

    • Clearing the rail immediately when the transaction is created would prevent duplicates, but would break the pre-mount/narrow-layout case the rail exists to solve.
    • Clearing whenever isFocused becomes true is too late for wide layouts and is the current source of stale IDs.
    • Removing the rail entirely would regress 1→2 report transitions and other cases where the table mounts after the optimistic transaction already exists.
  11. huult commented on Aug 17, 2026

    @huult
    Contributor

    Still checking

  12. huult commented on Aug 17, 2026

    @huult
    Contributor
    Screen.Recording.2026-08-17.at.13.58.51.mov

    @MelvinBot's proposal doesn't work, so we need 🆘 C+ Help Wanted.

  13. 60 remaining items

  14. huult commented on Sep 3, 2026

    @huult
    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.

      Link to the comment on the PR: https://github.com/Expensify/App/pull/83925/changes#r3920316066
      Link to the comment on the Issue:

    • [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:

    • An account with several workspace chats, each containing expense reports with more than one expense.

    Test:

    1. Clear the app cache / storage and reload.
    2. Open the Inbox and let a chat with expense report previews load.
    3. Verify no preview flashes the yellow highlight on existing expenses.
    4. Switch to another chat with expense previews, then back to the first one.
    5. Verify no preview flashes the highlight on either chat.
    6. Open a long chat via a link to an older report action (e.g. /r//), then scroll to pull more report actions into the list.
    7. Verify none of the existing previews flash the highlight as the expenses are existing ones.

    Do we agree 👍 or 👎

  15. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Sep 3, 2026
  16. melvin-bot commented on Sep 8, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  17. melvin-bot commented on Sep 8, 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
  18. mallenexpensify commented on Sep 10, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @FitseTLT due $250 via NewDot
    Contributor+: @huult due $250 via NewDot

  19. flaviadefaria commented on Sep 11, 2026

    @flaviadefaria
    Contributor

    Approved: @FitseTLT due $250 via NewDot

  20. JmillsExpensify commented on Oct 14, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @huult

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

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions