[$250] Reports- Tap back button on RHP navigate to thread instead of Spend - Expenses
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: 9.5.53-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: https://github.com/Expensify/App/pull/104926 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: Windows 11 Chrome App Component: Chat Report View
Action Performed:
Preconditions:
- Account with some expenses with comment inside
- Open https://staging.new.expensify.com/
- Navigate to Spend
- Click on 1 expense with atleast 1 comment inside
- Right click on the comment
- Click on "Reply in thread"
- Click on the parent comment in chat history
- Click on "<" back button on the expense detail RHP
Expected Result:
Verify that the Spend > Expenses list shows again.
Actual Result:
User is navigated to comment thread
Workaround:
Unknown
Platforms:
- [x] Android: App
- [ ] Android: mWeb Chrome
- [x] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [ ] MacOS: Chrome Safari
Screenshots/Videos
https://github.com/user-attachments/assets/0b339e1b-d2d0-4ee6-a471-65c1eace5885
Applause Internal Information Exported by: Julia Ponikarchuk Bug ID: 7322575
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022125097486422596139
- Upwork Job ID: 2125097486422596139
- Last Price Increase: 2026-11-27
While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/5f7e8c84105c84b45d22db98be90a54503b6b053695ee98d60d1e422cfbf5f34
Triggered auto assignment to Contributor-plus team member for initial proposal review - @samranahm (External)
Job added to Upwork: https://www.upwork.com/jobs/~022125097486422596139
🤖 Web test steps verification results: ⚠️ partial
Created a disposable $1.07 expense and comment. Verification stopped at an unsupported right-click operation, so the reported navigation bug remains unverified.

| Step | Status |
|---|---|
Open Spend > ExpensesInitially empty; the disposable expense appeared after creation.![]() |
✅ |
Open an expense with an existing commentReopened the expense and confirmed its saved comment.![]() |
✅ |
Right-click comment → Reply in threadDriver returned UNSUPPORTED_OPERATION for secondary-click; hovering exposed no reply action. |
❌ |
Click the parent commentBlocked before entering the thread. |
❌ |
Click expense header Back → Spend > ExpensesNot executed from the required thread-origin state. |
❌ |
Preliminary analysis — low confidence
Suspected mechanism: Parent-comment navigation can open another expense panel above the thread. Its Back button then pops that panel, revealing the thread instead of Spend.
Code evidence and important counterevidence
- The parent-comment click invokes the linked-report navigation helper: AncestorReportActionItem.tsx:121–142.
- Its fallback opens the ancestor expense with
backTo: SearchReport: ReportUtils.ts:12454–12461. - The header interprets that value as ordinary history-back, consistent with returning to the thread: ReportHeader.tsx:60–82.
However, the helper already checks whether the original expense is immediately below the thread. If found, it updates that expense and pops the thread rather than opening another panel: ReportUtils.ts:12440–12452. That should prevent the reported behavior in the straightforward stack.
The unresolved question is why this protection misses in the affected flow. A different stack shape or deployed implementation remains possible.
The QA-linked unsafe-assertion refactor does not establish causation: its relevant header changes are type-only, and the Back behavior already existed before that merge.
Required before recommending a fix: Capture the active panel stack, ancestor report ID, and selected navigation branch immediately before and after clicking the parent comment. This will distinguish a missed existing-expense match from a different navigation failure. Add regression coverage for the complete sequence through the final Back action; reverting type annotations is not supported by the evidence.
Proposal
Reproduced on staging web. The route IDs show the cause directly:
- Spend > Expenses → expense:
/search/view/6668534542846014?anchorTransactionID=...(the expense report). - Comment → Reply in thread:
/search/view/5808396084513355(the thread). - Click the parent comment: a new screen
/search/view/8951406895024852/<reportActionID>?backTo=SearchReportis pushed.8951406895024852is the expense's one-transaction thread, not the expense report below. <→ back on the thread (5808396084513355) instead of Spend > Expenses.
What is the root cause of that problem?
When the user clicks the parent comment, AncestorReportActionItem calls navigateToLinkedReportAction. In the RHP it already has a guard for this exact flow: if the route under the thread is the ancestor's report, it updates that route and pops the thread instead of pushing a new screen:
https://github.com/Expensify/App/blob/main/src/libs/ReportUtils.ts#L12440-L12452
The guard misses because of one-expense reports. Opening an expense from Spend > Expenses opens SEARCH_REPORT with the expense report's ID (/search/view/<expenseReportID>?anchorTransactionID=...). In that combined view, comments are posted to the one-transaction thread, not the expense report (useComposerReportData → getOneTransactionThreadReportID). So:
ancestor.report.reportIDis the transaction thread ID.routeBelow.params.reportIDis the expense report ID, which is the transaction thread's parent.
They never match. The code falls through to Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID: <transaction thread>, ...})) and pushes a third screen on top of the thread. Pressing < on that screen pops back to the thread, which is the reported bug.
What changes do you think we should make in order to solve the problem?
In navigateToLinkedReportAction, make the existing "route below" guard also recognize the expense report that displays the ancestor transaction thread:
- Compute
isAncestorShownInRouteBelow:- true if
routeBelowParams.reportID === ancestor.report.reportID(today's case); - or if the ancestor is a transaction thread (
isReportTransactionThread(ancestor.report)) androuteBelowParams.reportID === ancestor.report.parentReportID, i.e. the screen below is the one-expense report that renders that thread's actions.
- true if
- When it's true, keep today's behaviour:
setParams({reportActionID})on the route below so the combined view scrolls to and highlights the parent comment, thenNavigation.goBack()to pop the thread. - Everything else is unchanged:
- Multi-expense reports and other ancestors still push
SEARCH_REPORTas today. - The wide-layout (non-RHP) branch is unchanged.
- Multi-expense reports and other ancestors still push
After the fix: thread → click parent comment → back on the expense with the comment highlighted → < returns to Spend > Expenses.
Tests (unit tests for navigateToLinkedReportAction with a mocked RHP state):
- Route below = expense report and ancestor = its one-transaction thread:
setParamson the route below plusgoBack, and nonavigate. - Route below = same report ID as the ancestor: same as above (existing behaviour preserved).
- Route below is an unrelated report:
navigate(SEARCH_REPORT)as today. - Ancestor is a non-transaction-thread report whose
parentReportIDmatches the route below: stillnavigate(the new branch only applies to transaction threads).
What alternative solutions did you explore? (Optional)
- Change the
backTo/ back-button handling inReportHeaderso<skips the thread. That treats the symptom: the extra screen would still be pushed, and the stack would keep a duplicate expense screen. - Navigate with the expense report ID instead of the thread ID in the fallback. That still pushes a duplicate of the screen already below. Reusing the route below, like the existing guard does, is cleaner.
Proposal
What is the root cause of that problem?
The "already open below" guard in navigateToLinkedReportAction compares the wrong report IDs when an expense was opened from Spend > Expenses and belongs to a single-expense report, so clicking the parent comment pushes a duplicate RHP screen instead of popping back.
- Spend opens the expense report, not the transaction thread. For a single-expense report, the Spend list keeps
reportID = transactionItem.reportID(the expense report) and only switches toreportAction.childReportID(the transaction thread) for self-DM or multi-expense reports: Search/index.tsx#L787-L794. It then opensSEARCH_REPORTwith that expense report ID: Search/index.tsx#L898-L910. - Comments are stored on the transaction thread. In that combined single-expense view, the composer writes comments to
effectiveTransactionThreadReportID ?? reportID: useComposerSubmit.ts#L51-L52 via useComposerReportData.ts#L32-L35. "Reply in thread" therefore creates a child of the transaction thread and pushes it as anotherSEARCH_REPORTonto the same RHP (Report/index.ts#L3055-L3061), leaving the RHP stack as[SEARCH_REPORT(expenseReportID), SEARCH_REPORT(commentThreadID)]. - The guard misses. Clicking the parent comment (AncestorReportActionItem.tsx#L124-L139) calls
navigateToLinkedReportAction, whose guard only goes back whenrouteBelowParams.reportID === ancestor.report.reportID(ReportUtils.ts#L12440-L12452). Hereancestor.reportis the transaction thread, whereasrouteBelowholds its parent expense report, so the IDs differ and the fallback pushesSEARCH_REPORT({reportID: transactionThreadID, reportActionID, backTo: SEARCH_REPORT})(ReportUtils.ts#L12454-L12461). - The duplicate screen is not redirected away.
OneTransactionThreadRedirectHandlerdeliberately skips routes that includereportActionID(OneTransactionThreadRedirectHandler.tsx#L86-L91), so the pushed transaction-thread screen remains above the comment thread. Its header Back button seesbackTo === SCREENS.RIGHT_MODAL.SEARCH_REPORTand calls plainNavigation.goBack()(ReportHeader.tsx#L65-L68), returning to the comment thread instead of Spend > Expenses.
This also explains why the guard already works for multi-expense reports and self-DM expenses: in those flows Spend opens the transaction thread itself, so the IDs match.
What changes do you think we should make in order to solve the problem?
In navigateToLinkedReportAction (ReportUtils.ts#L12440-L12452), extend the "ancestor is already open below" check to also recognize the combined single-expense report case:
- Keep the existing exact match (
routeBelowParams.reportID === ancestor.report.reportID). - Also treat
routeBelowas a match whenrouteBelowParams.reportID === ancestor.report.parentReportIDandancestor.reportis specifically that parent's one-transaction thread, verified with the existingisOneTransactionThread(ancestor.report, parentReport, parentReportAction)helper (ReportUtils.ts#L3053-L3071) using the Onyx report and parent report action lookups already inReportUtils. CheckingisOneTransactionThreadrather than onlyisReportTransactionThreadis critical so a multi-expense parent report sitting below in the RHP (which does not render its child transaction threads' comments inline) does not false-match and pop away from the transaction thread. - When either condition matches, keep the existing behavior: call
setParams({reportActionID})onrouteBelowso the combined single-expense view scrolls to and highlights the parent comment, then callNavigation.goBack(). The RHP stack cleanly returns to[SEARCH_REPORT(expenseReportID)], and tapping<closes the RHP back to Spend > Expenses.
No changes are needed in ReportHeader, OneTransactionThreadRedirectHandler, or Search/index.tsx, preserving multi-expense/self-DM flows, reportActionID deep links, and the non-RHP (isInNarrowPaneModal === false) path.
Add unit test coverage for navigateToLinkedReportAction verifying:
- RHP stack
[SEARCH_REPORT(singleExpenseParentReport), SEARCH_REPORT(commentThread)]with a one-transaction-thread ancestor callssetParams+goBackand does not callnavigate. - RHP stack where
routeBelowis a multi-expense parent report (not a one-transaction thread) still falls through tonavigateinstead of popping back to the parent report. - Existing exact-ID match and unrelated-report cases remain unchanged.
What alternative solutions did you explore? (Optional)
- Checking only
isReportTransactionThread(ancestor.report)withparentReportID: Rejected because any transaction thread under a multi-expense report also passesisReportTransactionThread, which would falsely pop back to a multi-expense parent report that does not render that transaction's comments inline. - Letting
OneTransactionThreadRedirectHandlerredirect even whenreportActionIDis set: Rejected because the redirected screen would still sit above the comment thread on the RHP stack (so Back would still land on the thread) and it would regress comment deep links into one-transaction threads. - Altering
ReportHeaderBack behavior forbackTo === SEARCH_REPORT: Rejected because it masks the duplicate screen on the stack and would break legitimate report-to-report back navigation in Search.
@samranahm Melvin's analysis leaves open why the route-below check in navigateToLinkedReportAction misses, and the answer is the IDs: for a one-expense report, Spend opens the RHP on the expense report's reportID, not the transaction thread's:
https://github.com/Expensify/App/blob/d7c37c01c1f789576fce663d34cc8255e4a55f51/src/components/Search/index.tsx#L787-L795
Comments typed in that combined view are written to the transaction thread instead:
https://github.com/Expensify/App/blob/d7c37c01c1f789576fce663d34cc8255e4a55f51/src/pages/inbox/report/ReportActionCompose/useComposerSubmit.ts#L51-L52
So in the reply thread ancestor.report is the transaction thread, the reportID comparison fails, and the fallback pushes a SEARCH_REPORT for it with backTo: SCREENS.RIGHT_MODAL.SEARCH_REPORT, whose Back pops straight to the thread; I tested this locally — after clicking the parent comment the RHP stack is [expense report, thread, transaction thread], and Back lands on the thread. Treating the route below as a match when it is the one-expense parent of ancestor.report (its parentReportID) and just popping back to it fixes this inside that one helper, without touching Search or the composer.
Happy to put up a full proposal for this if that's useful.
Proposal
Please re-state the problem that we are trying to solve in this issue.
From Spend > Expenses, opening an expense that has a comment, replying in thread, clicking the parent comment, and then tapping the "<" back button on the expense detail RHP takes the user to the comment thread instead of back to the Spend > Expenses list.
What is the root cause of that problem?
The "ancestor is already open below" guard in navigateToLinkedReportAction (src/libs/ReportUtils.ts) only compares exact report IDs, and it misses in the one-expense case. Verified on baseline e91964cb:
- Spend opens the expense report, not the transaction thread, for a one-expense report.
Search/index.tsxonly switchesreportIDto the transaction thread'schildReportIDfor self-DM or multi-expense reports, so a one-expense report opensSEARCH_REPORTwith the expense report's ID. - Comments in that combined view are written to the transaction thread, not the expense report (
useComposerReportDataresolveseffectiveTransactionThreadReportID, anduseComposerSubmittargets it). "Reply in thread" therefore pushes a secondSEARCH_REPORTfor the comment thread on top of the expense report. - Clicking the parent comment calls
navigateToLinkedReportActionwithancestor.reportset to the transaction thread. The RHP guard only pops back whenrouteBelowParams.reportID === ancestor.report.reportID, but the route below holds the transaction thread's parent expense report, so the IDs differ and the code falls through to pushing a third screen:SEARCH_REPORTfor the transaction thread withbackTo: SEARCH_REPORT. - That third screen keeps its
reportActionID, soOneTransactionThreadRedirectHandlerdeliberately skips redirecting it, and its header Back button seesbackTo === SEARCH_REPORTand calls plainNavigation.goBack(), landing on the comment thread. That is the reported bug.
What changes do you think we should make in order to solve the problem?
In navigateToLinkedReportAction, extend the RHP "already open below" guard to also recognize the one-expense parent below, in src/libs/ReportUtils.ts only:
- Keep the existing exact match (
routeBelowParams.reportID === ancestor.report.reportID), with its current behaviour of settingreportActionIDon the route below and going back. - Also treat the route below as a match when
routeBelowParams.reportID === ancestor.report.parentReportIDand the ancestor is that parent's one-transaction thread, verified with the existingisOneTransactionThread(ancestor.report, parentReport, parentReportAction, isOffline)helper. The parent report and parent report action are looked up the same waygetDisplayedReportIDalready does in this file (deprecatedAllReportsandgetReportAction), andisOfflineis passed through for the deleted-IOU offline edge. UsingisOneTransactionThreadrather than onlyisReportTransactionThreadmatters: any transaction thread passesisReportTransactionThread, so that check alone would wrongly pop back to a multi-expense parent report that does not render the thread's comments inline. With the stricter check, a multi-expense parent still falls through to pushing a new screen, as today. - When the one-transaction parent matches, just call
Navigation.goBack()with nosetParams. The parent comment is an action on the transaction thread, not on the expense report, so setting itsreportActionIDon the expense report route cannot scroll to or highlight it:LinkedActionNotFoundGatelooks the action up only in the expense report's actions and finds nothing, and neither scroll hook finds it in the expense report's rendered actions, so there is no scroll target. Popping back without the param lands on the expense report as it was, and tapping "<" there returns to Spend > Expenses.
No changes are needed in ReportHeader, OneTransactionThreadRedirectHandler, or Search/index.tsx, and the non-RHP (wide layout) branch is unchanged.
Tests added in tests/unit/NavigateToLinkedReportActionTest.ts (Given/When/Then style, RHP stack mocked through navigationRef): the one-expense parent below pops back with no navigate and no setParams; a multi-expense parent below still pushes a new screen for the thread; the existing exact-ID match still sets reportActionID and pops back; an unrelated route below still pushes a new screen; and a missing parent report in Onyx safely falls through to pushing a new screen.
Evidence: the 5 new tests pass (5/5) and the first test fails on the clean baseline (the bug reproduces: navigate is called instead of goBack). oxlint reports 0 errors on the new test file and no new errors on ReportUtils.ts (137 pre-existing errors on the file before and after the change, none on the changed lines); spell check clean; React Compiler compliance check passed. Full typecheck could not be run on this machine: the TypeScript compiler process is killed before emitting diagnostics (a known limitation of this 6 GB VM; no diagnostics were emitted before the process was killed); the changes keep their declared types and the type-aware lint rules pass on all changed files.
This pops back to the expense report as it was, without scrolling to or highlighting the parent comment, which lives on the transaction thread.
What alternative solutions did you explore? (Optional)
- Checking only
isReportTransactionThread(ancestor.report)withparentReportID: Rejected because any transaction thread under a multi-expense report also passesisReportTransactionThread, which would falsely pop back to a multi-expense parent report that does not render that transaction's comments inline. The new unit test for the multi-expense parent proves this distinction. - Setting
reportActionIDon the expense report route below so the combined view scrolls to the parent comment: Rejected because the comment is not in the expense report's actions collection, so no scroll target exists:LinkedActionNotFoundGatelooks it up only in the expense report's actions and finds nothing, and neither scroll hook finds it in the expense report's rendered actions. Popping back without the param avoids that churn. - Altering
ReportHeaderBack behavior forbackTo === SEARCH_REPORT: Rejected because it masks the duplicate screen on the stack and would break legitimate report-to-report back navigation in Search. - Letting
OneTransactionThreadRedirectHandlerredirect even whenreportActionIDis set: Rejected because the redirected screen would still sit above the comment thread on the RHP stack (so Back would still land on the thread) and it would regress comment deep links into one-transaction threads.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~013b564a690d9bcdab
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Proposal
Please re-state the problem that we are trying to solve in this issue?
When opening an expense report from Spend > Expenses into the Right Hand Panel (RHP), replying in a comment thread, tapping the parent comment in chat history to return to the parent expense report, and then tapping the < back button in the header, the user is navigated back to the comment thread instead of returning to Spend > Expenses.
What is the root cause of that problem?
In src/pages/inbox/ReportHeader.tsx (lines 51–73):
const onBackButtonPress = (prioritizeBackTo = false, options?: {afterTransition?: () => void}) => {
if (isInSidePanel) {
closeSidePanel({afterTransition: options?.afterTransition});
return;
}
if (backTo === SCREENS.RIGHT_MODAL.SEARCH_REPORT) {
Navigation.goBack(undefined, options);
return;
}
if (prioritizeBackTo && backTo) {
Navigation.goBack(backTo as Route, options);
return;
}
if (isInNarrowPaneModal) {
Navigation.goBack(undefined, options);
return;
}
if (backTo) {
Navigation.goBack(backTo as Route, options);
return;
}
Navigation.goBack(undefined, options);
};
- When opening the expense from Spend > Expenses, the RHP route params contain
backTopointing to the Spend route. - When the user opens a comment thread, the thread is pushed onto the RHP navigation stack.
- When the user taps the parent comment link inside the thread,
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(parentReportID))pushes a new instance of the parent report onto the RHP navigation stack without preserving the originalbackToparam. - Furthermore, in
onBackButtonPress,if (isInNarrowPaneModal)(lines 64–67) executesNavigation.goBack(undefined, options)before checkingbackTo. Because it performs an unparameterizedNavigation.goBack(), it simply pops the topmost screen on the RHP stack, returning the user to the child thread previously pushed below it, rather than exiting the RHP to Spend > Expenses.
What changes do you think we should make in order to solve the problem?
- In
src/pages/inbox/ReportHeader.tsx: When an expense report in RHP was opened from Spend/Search, respectbackToor dismiss the modal when pressing the back button from the root expense report:
const onBackButtonPress = (prioritizeBackTo = false, options?: {afterTransition?: () => void}) => {
if (isInSidePanel) {
closeSidePanel({afterTransition: options?.afterTransition});
return;
}
if (backTo === SCREENS.RIGHT_MODAL.SEARCH_REPORT) {
Navigation.goBack(undefined, options);
return;
}
if (backTo) {
Navigation.goBack(backTo as Route, options);
return;
}
if (isInNarrowPaneModal) {
Navigation.goBack(undefined, options);
return;
}
Navigation.goBack(undefined, options);
};
- When navigating from a thread to its parent report via header or parent comment press, navigate to the parent report using navigation state unwind or forward the original
backToparameter, ensuring the parent report retains its entry-point route metadata.
What alternative solutions did you explore? (Optional)?
Always calling Navigation.dismissModal() on RHP back press was considered, but would prevent navigating back from child sub-modals (e.g., editing description or category). Checking backTo before isInNarrowPaneModal ensures configured exit routes are honored while sub-screen back navigation remains intact.
What specific scenarios should we cover in automated tests to prevent reoccurrence?
Add automated unit tests in tests/ui/ReportHeaderTest.tsx:
- RHP Back Navigation with backTo: Verify that clicking the back button in
ReportHeaderon an RHP screen withbackTonavigates tobackToeven whenisInNarrowPaneModalis true. - Thread to Parent Unwind: Verify that navigating from Spend > Expenses into an expense, opening a thread, returning to the parent report, and clicking back returns to Spend > Expenses.
Contributor details?
- Email: [email protected]
- Upwork Profile: https://www.upwork.com/freelancers/~0131dae36abcf59374
@Xch4rt @colton-summerlin @dankezo @kevinjosh10 Thank you all for your interest in contributing to Expensify! Please only post proposal if Help Wanted label has been applied. Also, take a look at CONTRIBUTING.md to get familiar with the guidelines.
@samranahm
I traced the open question in Melvin's analysis: from Spend, a one-expense report opens on the expense report ID, but the parent comment lives on its transaction thread, so the route-below check in navigateToLinkedReportAction (ReportUtils.ts#L12448) never matches and an extra screen gets pushed on top of the thread.
I'd suggest matching the route below against getDisplayedReportID(ancestor.report.reportID) and just going back without setParams, since linking a thread comment on the expense report route empties its action list. I have this working with a test that fails on main, and I'll post a full proposal once Help Wanted is applied.
@MelvinBot Post your proposal.
Proposal
What is the root cause of that problem?
The parent-comment navigation fails to recognize that the expense is already open underneath the comment thread.
For a single-expense report, Spend opens the expense report, but its comments belong to the transaction thread. The existing navigation check compares those different report IDs, misses the already-open expense, and pushes another screen. Back then returns to the comment thread instead of Spend.
This confirms the report-ID mismatch identified in the contributor comments.
Code evidence
- Search/index.tsx:785–795 selects the expense-report ID for single-expense reports.
- useReportActionsPagination.ts:97–104 combines transaction-thread comments into that view.
- ReportUtils.ts:12592–12613 only reuses the underlying route for an exact report-ID match; otherwise, it navigates forward.
- ReportHeader.tsx:60–81 correctly pops that extra screen, exposing the comment thread.
What changes do you think we should make in order to solve the problem?
Extend the existing reuse check in the navigation helper:
- Preserve the exact-ID match and its current behavior.
- Separately recognize when the underlying route displays the ancestor’s transaction thread, using the existing getDisplayedReportID helper, passing through the offline state.
- Require the parent’s transaction count to be one, preventing partially loaded multi-expense reports from matching accidentally.
- For this displayed-parent match, simply go back—without setting
reportActionID. That comment belongs to the transaction thread, while the linked-action lookup reads the route report’s own actions. - Leave other navigation paths unchanged.
This returns to the original expense panel; its next Back returns to Spend. It preserves the existing view rather than adding a new comment highlight.
Regression coverage: single-expense reuse without changing parameters; existing exact-ID behavior; unrelated or missing data; multi-expense parents—including partially loaded actions; self-DM expenses; offline handling; and the complete reported navigation sequence.
Verification: Code-traced against the current checkout; no new browser reproduction or tests were performed for this proposal.
What alternative solutions did you explore? (Optional)
Changing header Back behavior would hide the extra navigation rather than prevent it. Matching only the ancestor’s parent ID is too broad because multi-expense parents do not display transaction-thread comments inline.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/107808) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
@MelvinBot I tested your proposal locally, it fix the main issue but has one problem. When I click parent comment in thread to go back to expense report, the comment does not highlight anymore. Find the underlying problem and update your proposal.
Proposal
Updated based on samranahm’s testing: returning to the expense must also scroll to and highlight the parent comment. My previous proposal incorrectly dropped that requirement.
What is the root cause of that problem?
There are two related problems:
- Navigation compares storage IDs rather than the displayed report. The expense panel uses the expense-report ID, while its inline comments belong to the transaction thread. The comparison misses and opens another panel.
- Linked-comment handling assumes the displayed report owns the comment. Simply going back removes the highlighting request. Restoring
reportActionIDalone is insufficient: pagination and missing-action validation look for that thread comment in the expense report’s actions.
The underlying inconsistency is that the combined expense view displays actions from two reports, but linked-action handling does not consistently distinguish where an action is displayed from which report owns it.
Supporting code evidence
- ReportUtils.ts:12592–12613: exact-ID reuse sets the comment target before going back.
- useReportActionsPagination.ts:53–104: the route’s anchor is applied to parent pagination before discovering and combining thread actions.
- PaginationUtils.ts:391–410: an anchor absent from that collection produces an empty page.
- LinkedActionNotFoundGuard.tsx:61–106: validation checks only the route report’s collection and can clear the valid thread-comment target.
- ReportActionItem.tsx:267–275: highlighting already works when the retained target ID matches the rendered action.
What changes do you think we should make in order to solve the problem?
- Reuse the existing expense panel, retaining the narrowly scoped single-expense match from the previous proposal.
- Set the comment target before going back. Preserve the expense route and its existing parameters, but carry both the comment ID and its owning transaction-thread ID. The ancestor click already supplies both.
- Separate parent pagination from thread targeting. Discover the inline thread independently of the comment anchor. Apply the anchor to the owning thread’s page—not the expense report’s page—then combine the actions.
- Use the same owner for validation and fetching. Validate the alternate owner against the thread actually displayed by this expense. Fetch missing comments from that thread and wait for its loading result before clearing an unavailable target.
- Keep the existing highlight implementation. Ensure positioning runs when the target becomes available, including after loading. Clear any added targeting metadata when clearing the anchor.
No header Back change is needed.
Regression coverage: parent comment scrolls into view and highlights; subsequent Back reaches Spend; uncached/offscreen targets; genuinely unavailable comments; repeated parent-comment navigation; and unchanged exact-ID, multi-expense, self-DM, and offline behavior.
Verification: Source-level investigation only; the revised changes have not been implemented or browser-tested.
What alternative solutions did you explore? (Optional)
- Go back without an anchor: fixes navigation but loses highlighting.
- Restore only
reportActionID: leaves pagination and validation reading the wrong collection. - Change header Back behavior: masks the extra panel rather than correcting navigation.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/107808) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
Melvin's direction is right, but the proposal is way broader than this bug needs. Ideally we should keep the change in navigateToLinkedReportAction and reuse the screen below when it shows the ancestor's one-transaction thread (getDisplayedReportID plus a transaction count of 1). Set only reportActionID there so we don't add a new route param.
Expected result: clicking the parent comment goes back to the expense and highlights the comment, and clicking the app back button then returns to "Spend" > "Expenses".
Opening the issue for External Contributors. Please check your solution locally and provide a POC video.
🆘 C+ Help Wanted
🚨 Edited by proposal-police: This proposal was edited at 2026-11-28 08:56:27 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue?
On web, when opening a single-expense report from Spend > Expenses, replying in thread to a comment, and clicking the parent comment in the thread chat history to return to the expense, clicking the < (Back) button navigates back to the comment thread instead of returning to Spend > Expenses.
Reproduction
Environment:
- Platform: Desktop Web
- Build: Staging (
staging.new.expensify.com)
Reproduction Nuance:
To reproduce, the expense must belong to a Workspace (or submitted report with 1 transaction). For personal/standalone IOU expenses, the expense report and transaction thread share the identical report ID, masking the defect. In Workspace reports, Expensify separates the Expense Report (R) and the Transaction Report (T). Clicking the parent comment targets T while the screen open below in RHP is R.
Steps to Reproduce:
- Ensure the account has a Workspace with at least one submitted expense containing a comment.
- Navigate to Spend > Expenses.
- Click on the Workspace expense (opens in RHP).
- Hover on the comment → click
...→ click Reply in thread. - In the thread panel on the right, click directly on the parent comment message text in the chat history.
- The panel transitions back to the expense report view.
- Click the
<(Back) arrow button in the top-left of the header.- Bug (Before): Instead of returning to Spend > Expenses, the app navigates right back into the comment thread!
- Expected (After): The RHP closes and cleanly returns the user to the Spend > Expenses list.
Video Evidence:
- Before Video (Reproduction of Bug on Staging):
Watch Before Video - After Video (Proof of Concept Fix):
Watch After Video
What is the root cause of that problem?
The bug is caused by a report ID mismatch when navigating back from a thread to a one-transaction parent expense in navigateToLinkedReportAction:
-
Stack Mismatch in
ReportUtils.ts:12668:
When the thread is opened from a one-transaction Workspace expense report, the screen below the thread in the RHP stack is the Expense Report (routeBelowParams.reportID = R). However, the parent comment belongs to the underlying transaction thread report (ancestor.report.reportID = T).In
src/libs/ReportUtils.ts:if (routeBelow?.key && routeBelowParams?.reportID === ancestor.report.reportID) { Navigation.setParams({reportActionID: ancestor.reportAction.reportActionID}, routeBelow.key, rhpState?.key); Navigation.goBack(); return; }Because
routeBelowParams.reportID(R) does not equalancestor.report.reportID(T), this equality check fails. -
Unnecessary Screen Push with
backTo: SearchReport:
Because the check fails, the helper falls through to:Navigation.navigate( ROUTES.SEARCH_REPORT.getRoute({ reportID: ancestor.report.reportID, reportActionID: ancestor.reportAction.reportActionID, backTo: SCREENS.RIGHT_MODAL.SEARCH_REPORT, }), );This pushes an extra
SEARCH_REPORTscreen on top of the RHP stack withbackTo: SCREENS.RIGHT_MODAL.SEARCH_REPORT, resulting in an RHP stack of[R, thread, T]. -
Back Button Trapping in
ReportHeader.tsx:65-68:
When the user taps the<(Back) button on that newly pushed screen,ReportHeader.tsxexecutes:if (backTo === SCREENS.RIGHT_MODAL.SEARCH_REPORT) { Navigation.goBack(undefined, options); return; }Navigation.goBack()simply popsT, uncovering the screen directly underneath it on the stack: the thread!
What changes do you think we should make in order to solve the problem?
-
In
src/libs/ReportUtils.tsinsidenavigateToLinkedReportAction: Check ifrouteBelowis the ancestor's parent report or one-transaction parent:const routeBelowReport = deprecatedAllReports?.[`${ONYXKEYS.COLLECTION.REPORT}${routeBelowParams?.reportID}`]; const isRouteBelowParentReport = routeBelow?.key && (routeBelowParams?.reportID === ancestor.report.reportID || routeBelowParams?.reportID === ancestor.report.parentReportID || (routeBelow?.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT && (isOneTransactionReport(routeBelowReport) || routeBelowParams?.reportID === getDisplayedReportID(ancestor.report.reportID, isOffline)))); if (isRouteBelowParentReport && routeBelow?.key) { Navigation.setParams({reportActionID: ancestor.reportAction.reportActionID}, routeBelow.key, rhpState?.key); Navigation.goBack(); return; } -
In
src/pages/inbox/LinkedActionNotFoundGuard.tsx: For one-transaction reports, also query the inline transaction thread's actions (useOneTransactionThreadReportID) so thatisLinkedActionUnavailabledoes not prematurely stripreportActionIDfor valid thread comments, keeping the amber highlight intact:const oneTransactionThreadReportID = useOneTransactionThreadReportID(reportIDFromRoute); const [linkedActionFromReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportIDFromRoute}`, { selector: (actions: OnyxEntry<ReportActions>) => getReportActionByIDSelector(actions, reportActionIDFromRoute), }); const [linkedActionFromThread] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${oneTransactionThreadReportID}`, { selector: (actions: OnyxEntry<ReportActions>) => getReportActionByIDSelector(actions, reportActionIDFromRoute), }); const linkedAction = linkedActionFromReport ?? linkedActionFromThread;
Why this resolves all requirements:
- Comment Highlighting: Querying the transaction thread in
LinkedActionNotFoundGuardensures the comment is recognized as valid and maintains the amber highlight. - Clean Stack: Instead of pushing an extra screen
[R, thread, T], it pops the thread, returning torouteBelow(R). BecauserouteBelowretains its originalbackTopointing to Spend > Expenses, clicking<onrouteBelowcloses the RHP and returns straight to Spend > Expenses. - Multi-Transaction Safety: Reports with multiple transactions continue on their existing path without regressions.
What alternative solutions did you explore? (Optional)
- Setting only
reportActionIDwithout updatingLinkedActionNotFoundGuard:
LeavesrouteBelowParams.reportIDpointing toR. Because the comment action belongs toTand notR,LinkedActionNotFoundGuardcannot resolve the action withinR, triggering an auto-navigate that wipesreportActionIDand loses the highlight. Extending the guard to check the inline thread preserves the highlight cleanly. - Handling back-navigation in
ReportHeader.tsx:
Attempting to check previous route history inReportHeader.tsxis fragile and risks breaking normal back-navigation flows for threads and sub-screens across the app. Fixing the navigation dispatch at the source innavigateToLinkedReportActionis surgical and self-contained.
What specific scenarios should we cover in automated tests to prevent reoccurrence?
Add unit tests in tests/unit/ReportUtilsTest.ts:
- One-transaction parent report with thread:
Simulate an RHP stack of[one-transaction report, thread]whereancestor.reportis the transaction thread. Verify that callingnavigateToLinkedReportActioncallsNavigation.setParams({reportActionID})onrouteBelowandNavigation.goBack(), with zero calls toNavigation.navigate. - Multi-transaction report (
transactionCount > 1):
Verify that whenrouteBelowReporthas multiple transactions,navigateToLinkedReportActioncontinues to callNavigation.navigatewithbackTo: SCREENS.RIGHT_MODAL.SEARCH_REPORT. - Add a test in
LinkedActionNotFoundGuardTest.tsxverifying that a thread comment'sreportActionIDis not cleared when viewed from its one-transaction parent report.
Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374
🚨 Edited by proposal-police: This proposal was edited at 2026-11-30 11:45:46 UTC.
Proposal
Updated: added the transactionCount === 1 check you asked for, limited the reuse to the SEARCH_REPORT screen, and explained why the reused screen needs the thread's reportID for the highlight. Tests added for each.
Please re-state the problem that we are trying to solve in this issue.
Open a one-expense report from Spend > Expenses, reply in thread to a comment, then tap the parent comment at the top of the thread. A duplicate expense screen is pushed, and its < returns to the comment thread instead of Spend > Expenses. Tapping the parent comment should go back to the expense with the comment highlighted, and < should then return to Spend > Expenses.
What is the root cause of that problem?
Spend opens a one-expense report on the expense report ID. It only opens the transaction thread for self-DM and multi-expense reports (Search/index.tsx#L795-L801). That screen shows the transaction thread's comments inline, so the parent comment belongs to the transaction thread.
Tapping the parent comment calls navigateToLinkedReportAction, which reuses the screen below only on an exact ID match (ReportUtils.ts#L12696). Expense report ≠ transaction thread, so it pushes SEARCH_REPORT(transactionThread, backTo: SEARCH_REPORT) on top of the comment thread. That screen's < is a plain goBack(), which lands on the comment thread.
What changes do you think we should make in order to solve the problem?
Keep the fix in navigateToLinkedReportAction, as you suggested. Reuse the screen below when it is the report that displays the ancestor:
getDisplayedReportID(ancestor)equals the report below (the parent of a one-transaction thread), and- the report below has
transactionCount === 1(isOneTransactionReport).getDisplayedReportIDdecides from the loaded actions, so a multi-expense report with only one expense loaded would otherwise match. The server count prevents that, and - the screen below is
SEARCH_REPORT. Spend > Reports and Home open a report inSEARCH_MONEY_REQUEST_REPORT/EXPENSE_REPORT(Search/index.tsx#L858), which renderSearchMoneyRequestReportPagefrom the route'sreportIDand can't show a transaction thread. Those keep today's behavior instead of being pointed at the thread.
diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts
index 4e377a8eb2c9..e051aae10f02 100644
--- a/src/libs/ReportUtils.ts
+++ b/src/libs/ReportUtils.ts
@@ -12693,8 +12693,17 @@ function navigateToLinkedReportAction(
const routeBelow = rhpIndex > 0 ? rhpState?.routes.at(rhpIndex - 1) : undefined;
const routeBelowParams = routeBelow?.params as {reportID?: string} | undefined;
- if (routeBelow?.key && routeBelowParams?.reportID === ancestor.report.reportID) {
- Navigation.setParams({reportActionID: ancestor.reportAction.reportActionID}, routeBelow.key, rhpState?.key);
+ // A one-expense report shows its transaction thread's comments inline. The server's transactionCount keeps a partly loaded multi-expense report from matching.
+ // Only SEARCH_REPORT can be pointed at the thread: Spend > Reports and Home open the report in the money request report page, which can't show a thread.
+ const isAncestorShownInRouteBelow =
+ routeBelowParams?.reportID === ancestor.report.reportID ||
+ (routeBelow?.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT &&
+ !!ancestor.report.reportID &&
+ routeBelowParams?.reportID === getDisplayedReportID(ancestor.report.reportID, isOffline) &&
+ isOneTransactionReport(getReport(routeBelowParams.reportID, deprecatedAllReports)));
+
+ if (routeBelow?.key && isAncestorShownInRouteBelow) {
+ Navigation.setParams({reportID: ancestor.report.reportID, reportActionID: ancestor.reportAction.reportActionID}, routeBelow.key, rhpState?.key);
Navigation.goBack();
return;
}
Why the reused screen also gets the thread's reportID, not only reportActionID: with only reportActionID on the expense report route, the highlight is lost, which is what you saw when testing Melvin's first version. LinkedActionNotFoundGuard looks the action up in the route report's actions (LinkedActionNotFoundGuard.tsx#L65-L67). The comment belongs to the transaction thread, so it isn't found and once loading finishes the guard treats it as unavailable and clears reportActionID (#L105-L106, #L144-L148). Pointing the reused route's existing reportID at the thread fixes that, and still adds no new route param:
reportIDandreportActionIDare both params that route already has. The route key, itsbackTo, and its place in the stack stay the same, so<dismisses the RHP to Spend > Expenses.- The comment is found in the thread's actions, so it is scrolled to and highlighted.
- The thread screen is the same expense view Spend already opens for multi-expense and self-DM expenses (Search/index.tsx#L799-L800). It shows the expense details, and the wide RHP receipt panel still shows because the thread's parent action is a transaction (WideRHPReceiptPanel.tsx#L75). It is not redirected back while
reportActionIDis set (OneTransactionThreadRedirectHandler.tsx#L86-L91).
The exact-ID case is unchanged (its reportID is already the ancestor's), and the wide-layout branch is not touched.
Branch: https://github.com/samithreddychinni/App/tree/fix/107808-reuse-one-expense-search-report
Compare diff: https://github.com/Expensify/App/compare/main...samithreddychinni:App:fix/107808-reuse-one-expense-search-report
POC video:
https://github.com/user-attachments/assets/bb508d49-ea54-4c0e-8d10-1fbbe163dcd0
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
In tests/unit/ReportUtilsNavigateToLinkedReportActionTest.ts, with the RHP stack mocked:
- A one-expense report below the thread, and the ancestor is its transaction thread: the route below is reused with the thread's
reportIDandreportActionID, the thread is popped, and nothing is pushed. - A multi-expense report below (
transactionCount: 2) with only one expense loaded: a new screen is pushed, as today. - The one-expense report below is the
SEARCH_MONEY_REQUEST_REPORTpage (Spend > Reports): a new screen is pushed, as today. - The route below has the ancestor's exact ID: reused and popped, as today.
- An unrelated report below: pushed, as today.
- A non-transaction child of the report below: pushed, as today.
- No screen below: pushed, as today.
Test 1 fails on main (it pushes a new screen instead of going back). Test 2 fails without the transactionCount check, and test 3 fails without the SEARCH_REPORT check. All 7 pass on the branch, and lint and spell check pass on the changed files.
What alternative solutions did you explore? (Optional)
- Set only
reportActionIDon the expense report route: Back works, butLinkedActionNotFoundGuardcan't find the thread's comment in the expense report's actions, clears the param, and the highlight is lost. - Go back without any param: Back works, but there is no highlight.
- Teach the guard and pagination to read the thread's actions on the expense report route: this is the broad change Melvin's second version describes. It touches several files for something the existing
reportIDparam already handles. - Change
ReportHeaderBack: this hides the duplicate screen instead of not pushing it.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01cfe51584d8033bdc
Proposal
What is the root cause of that problem?
Tapping the parent comment calls navigateToLinkedReportAction. In the RHP it pops back to the screen below only when that screen has the ancestor's exact report ID. Otherwise it pushes a new SEARCH_REPORT with backTo: SEARCH_REPORT, and that screen's Back is a plain goBack():
https://github.com/Expensify/App/blob/d7c37c01c1f789576fce663d34cc8255e4a55f51/src/libs/ReportUtils.ts#L12446-L12461
In this flow the IDs never match. Spend opens a one-expense report on the expense report ID. It only switches to the transaction thread for self-DM and multi-expense reports:
https://github.com/Expensify/App/blob/d7c37c01c1f789576fce663d34cc8255e4a55f51/src/components/Search/index.tsx#L787-L795
But comments typed in that combined view are written to the transaction thread (useComposerReportData.ts#L32-L33, useComposerSubmit.ts#L51-L52). So after "Reply in thread", the parent comment's report is the transaction thread, while the screen below is the expense report. The check fails, and a third screen goes on top of the thread: [expense report, comment thread, transaction thread]. Back on that third screen pops to the comment thread.
The thread header's "From …" link doesn't have this problem, because HeaderView already resolves a one-transaction parent to its expense report and drops the action ID (HeaderView.tsx#L198-L199, #L494). The ancestor row is the entry point that misses it.
This isn't caused by #104926. The guard came in with #90680, and the flow reproduces on production too.
What changes do you think we should make in order to solve the problem?
I'd fix it in navigateToLinkedReportAction, RHP branch only, because that's where the decision between "pop back" and "push" is made.
After the existing exact-ID check, add one more case: if the route below is the report that displays the ancestor, go back to it. We already have a helper for this. getDisplayedReportID returns the expense report ID for a one-transaction thread and the same ID for anything else (ReportUtils.ts#L3098-L3112):
if (routeBelow?.key && routeBelowParams?.reportID === getDisplayedReportID(ancestor.report.reportID, isOffline)) {
Navigation.goBack();
return;
}
There's no setParams in this branch, on purpose. The parent comment's ID belongs to the transaction thread, not to the expense report. If we set it on the expense report route, the paginated actions look for it among the expense report's actions, don't find it, and return an empty list (PaginationUtils.ts#L406-L411). That same list is what the one-expense view uses to find its transaction thread (useReportActionsPagination.ts#L66), so the expense would render empty and fire OpenReport with an action ID from another report, until LinkedActionNotFoundGuard clears the param. Going back with no param shows the expense as the user left it, and its < closes the RHP back to Spend > Expenses.
What stays the same:
- When the transaction thread itself is below (multi-expense and self-DM flows open it directly), the exact-ID check still runs first, with
setParams+goBack. - A multi-expense report below doesn't match, because
getDisplayedReportIDreturns the thread's own ID there, so we still push the thread. That report doesn't show the thread's comments inline. - If the thread or its parent isn't in Onyx,
getDisplayedReportIDreturns the input ID, and we fall back to today's push. - The wide-layout branch isn't touched.
I tested this locally. I added tests/unit/NavigateToLinkedReportActionTest.ts with the RHP stack mocked:
- The one-expense case fails on
main(navigateis called,goBackisn't) and passes with the change. - "Multi-expense report below", "exact ID below" and "unrelated report below" all keep today's behavior.
ReportUtilsTest,AncestorReportActionItemTestand the new file pass: 1781/1781. Typecheck and lint are clean on the changed files.
What alternative solutions did you explore? (Optional)
- Link the comment on the expense report (
setParams+goBack) so it gets highlighted. I rejected this because of the empty-list problem above. Linking a thread's comment from the parent report's route isn't something the linked-action pagination supports today. - Resolve the ancestor in
AncestorReportActionItemand pass the expense report into the helper, the wayHeaderViewdoes. I rejected this because the wide-layout branch of the same helper needs the real ancestor ID forREPORT_WITH_IDand the visibility check. Swapping the report at the call site would change that path too. - Open the transaction thread from Spend instead of the expense report. I rejected this because Search opens the combined one-expense view on purpose, and changing it affects every Spend row, not just this flow.
