Skip to content

86919: Message in IOU is not scrolled to when navigating via link, 'submitted' not shown - #96428

Open
abbasifaizan70 wants to merge 11 commits into
Expensify:mainfrom
abbasifaizan70:fix-86919
Open

86919: Message in IOU is not scrolled to when navigating via link, 'submitted' not shown#96428
abbasifaizan70 wants to merge 11 commits into
Expensify:mainfrom
abbasifaizan70:fix-86919

Conversation

@abbasifaizan70

@abbasifaizan70 abbasifaizan70 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

When a message link is copied from a one-transaction expense, the link points at the transaction thread — so opening it showed the thread on its own, without the parent's "Submitted" system message, and without scrolling to the linked message.

This fixes it by deciding at open time which report to show, rather than rewriting the link when it is copied:

  • The copied link keeps pointing at the report that actually owns the action (the transaction thread), so a link can never go stale.
  • ReportFetchHandler redirects to the parent expense report while the thread is still that report's only transaction (shouldRedirectLinkedActionToParentReport), so the combined view opens with "Submitted" visible and the list anchors to the linked message. forceReplace keeps the redirect out of the history stack.
  • Once the report gains a second expense the redirect stops firing, and the previously copied link simply opens the thread — where the action still lives — so old links keep working.
  • LinkedActionNotFoundGuard also resolves the linked action in the transaction thread, since after the redirect the route is the parent while the action lives in the thread.
  • usePaginatedReportActions only drops the pagination anchor when the linked action is confirmed to be in the merged transaction thread, so a valid action that simply hasn't loaded yet still scrolls into view once OpenReport hydrates it.

Fixed Issues

$ #86919
PROPOSAL: #86919 (comment)

Tests

  • Verify that no errors appear in the JS console

1. Linked message opens the combined expense view (the reported bug)

  1. Sign in to ND as User A on the main device, and User B on a secondary device
  2. As User A, create a workspace and add User B as a member
  3. As User B, navigate to the workspace chat
  4. Create a single manual expense, open the expense details, and click Submit
  5. Send three messages in the expense details
  6. Right-click the 3rd message → Copy link → send the link to User A in a 1:1 chat
  7. As User A, open the 1:1 chat with User B and tap the link
  8. Verify the parent expense report opens and the list is scrolled to the 3rd message
  9. Verify the "Submitted" system message is visible in the timeline
  10. Verify the expense report's action buttons (e.g. Approve / Pay) are present
  11. On web, verify the URL updates from /r/<transactionThreadID>/<reportActionID> to /r/<expenseReportID>/<reportActionID>
  12. Press the back button and verify you return to the 1:1 chat, not the transaction thread

2. A previously copied link still works after the report gains more expenses

  1. Keep the same link copied in step 6 above — do not copy a new one
  2. As User B, add a second expense to that same expense report
  3. As User A, open that same link again
  4. Verify the transaction thread opens and the linked message is shown
  5. Verify no "The comment you are looking for cannot be found" page appears

("Submitted" is not expected here — the report is no longer a one-transaction expense, so the thread is correctly shown on its own.)

3. Regular chat message links are unchanged

  1. Copy a link to any message in a normal 1:1 or group chat and open it
  2. Verify no redirect happens, the URL is unchanged, and the list scrolls to the linked message

Offline tests

Same as tests.

QA Steps

  • Verify that no errors appear in the JS console

Same as tests.

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Screen.Recording.2026-07-18.at.3.37.35.AM.mov
Android: mWeb Chrome
Screen.Recording.2026-07-18.at.3.42.06.AM.mp4
iOS: Native
Screen.Recording.2026-07-18.at.2.58.01.AM.mov

Screen.Recording.2026-07-18.at.2.59.07.AM.mov
iOS: mWeb Safari
Screen.Recording.2026-07-18.at.3.02.19.AM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-08-26.at.3.51.50.AM.mov

Screen.Recording.2026-08-26.at.4.09.37.AM.mov

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/hooks/usePaginatedReportActions.ts 100.00% <100.00%> (+7.31%) ⬆️
src/hooks/useReportActionsPagination.ts 100.00% <100.00%> (ø)
src/pages/inbox/LinkedActionNotFoundGuard.tsx 91.37% <100.00%> (+1.18%) ⬆️
src/pages/inbox/ReportFetchHandler.tsx 88.09% <100.00%> (+0.41%) ⬆️
...es/inbox/report/ContextMenu/ContextMenuActions.tsx 41.28% <ø> (+0.71%) ⬆️
.../inbox/shouldRedirectLinkedActionToParentReport.ts 100.00% <100.00%> (ø)
... and 168 files with indirect coverage changes

@abdulrahuman5196

Copy link
Copy Markdown
Contributor

Do publish the PR if code changes are done

@abbasifaizan70
abbasifaizan70 marked this pull request as ready for review July 22, 2026 12:43
@abbasifaizan70
abbasifaizan70 requested review from a team as code owners July 22, 2026 12:43
@melvin-bot

melvin-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

@abdulrahuman5196 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot removed request for a team July 22, 2026 12:43
@abbasifaizan70

Copy link
Copy Markdown
Contributor Author

@abdulrahuman5196 Sorry, my bad. I just forgot to make it ready for review. Thanks for giving remainder.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a8a51d0c1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/hooks/usePaginatedReportActions.ts Outdated

@joekaufmanexpensify joekaufmanexpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good for product.

@abdulrahuman5196

Copy link
Copy Markdown
Contributor

Reviewing

@abdulrahuman5196

Copy link
Copy Markdown
Contributor

Same concern as Codex: in both usePaginatedReportActions and LinkedActionNotFoundGuard, how do we distinguish “action isn’t in this report’s loaded actions yet” from “action truly isn’t on this report (e.g. it lives on the merged transaction thread)”? Right now both paths treat “not found in the current collection” as decisive

#96428 (comment)

@abbasifaizan70

@abbasifaizan70

Copy link
Copy Markdown
Contributor Author

@abdulrahuman5196 Fixed: the anchor is now dropped only when the linked action is confirmed to live in the merged one-transaction thread, not merely when it's absent from the current report's cache. useReportActionsPagination resolves the transaction thread and passes an explicit isLinkedActionInMergedTransactionThread flag into usePaginatedReportActions; a not-yet-loaded action that belongs to this report keeps its anchor, so the list still scrolls to it once OpenReport hydrates it. Non-one-transaction reports resolve to no thread, so regular chat deep-links are unchanged. LinkedActionNotFoundGuard already gates its not-found decision on the loading cycle completing, so it doesn't treat mere absence as decisive. Added a unit test covering the not-loaded-yet case (keeps anchor, stays empty) alongside the merged-thread case (drops anchor, newest window).

@abdulrahuman5196

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 64267ad04c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx Outdated
@abbasifaizan70

Copy link
Copy Markdown
Contributor Author

@abdulrahuman5196 Implemented new solution as discussed in above chat. Thanks

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants