Skip to content

[Payment due @situchan] Hide unread markers on read reports - #100562

Open
deetergp wants to merge 54 commits into
mainfrom
deetergp/677837-hide-read-markers
Open

deetergp wants to merge 54 commits into
mainfrom
deetergp/677837-hide-read-markers

Conversation

@deetergp

@deetergp deetergp commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

This PR changes when two system messages show a “New” line:

  • Payment messages should show “New” for the submitter, not the payer. Auth tells the App who should be notified.
  • “Exported to NetSuite” should not show “New” for anyone unless they choose “Mark as unread.”

Other integrations keep working as before. This PR no longer changes how chats are marked read or unread, how messages load, how scrolling works, or the library that displays the message list. Choosing “Mark as unread” on a message still works as before.

The Auth change that tells the App who should be notified is already merged: https://github.com/Expensify/Auth/pull/24311.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/677837
PROPOSAL: N/A

Tests

Passed locally in desktop Chrome with submitter A and payer B. For the NetSuite test, we added an export message locally without sending data to NetSuite.

  1. Submit an expense report as A.
  2. Approve/pay it as B.
  3. Navigate both users to other chats before the payment message arrives.
  4. Confirm the report becomes unread for A only.
  5. Open the report as A and confirm “New” appears above the payment message.
  6. Open the report as B and confirm the payment alone creates no “New” divider.
  7. Read the report as both users.
  8. Navigate both users to other chats.
  9. Export the report to NetSuite, or add a manual NetSuite export action in the local environment.
  10. Confirm the export alone does not make the report unread for either user.
  11. Open the report as both users and confirm the export message is visible without a “New” divider above it.
  12. Navigate A to another chat.
  13. Post an ordinary comment as B.
  14. Confirm A’s report row becomes bold.
  15. Open the report as A and confirm “New” appears above B’s comment.
  • Verify that no errors appear in the JS console

Offline tests

These steps have not been tested manually yet. Automated tests passed for messages received while offline.

  1. Keep both users in other chats while a payment message arrives and syncs.
  2. Disconnect from the network before opening the report.
  3. Open it as A and confirm the payment has a “New” divider.
  4. Open it as B and confirm the payment alone does not make it unread or create a “New” divider.
  5. Reconnect and read the report as both users.
  6. Navigate away and let a NetSuite export message arrive and sync.
  7. Disconnect before reopening the report.
  8. Confirm the export alone creates neither an unread row nor a “New” divider for either user.

QA Steps

Repeat the Tests section on staging on each supported platform. Use a workspace with automatic reimbursement enabled, and switch to another chat before the payment completes.

  • Verify that no errors appear in the JS console

AI Tests

  • Passed 2,542 tests across ReportActionsUtilsTest, useUnreadMarkerTest, UnreadIndicatorsTest, useMarkAsReadTest, ReportTest, and ReportUtilsTest (2 skipped).
  • Passed typecheck, lint, formatting, spelling, and React Compiler checks.
  • Added tests to check who sees payment messages as unread, that NetSuite exports do not show “New,” and that ordinary comments still do. Tests also cover messages received offline, opening a report before all its messages have loaded, and choosing “Mark as unread” on a message.

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 verified any copy / text that was added to the app 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 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 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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.

Checklist notes: Chrome testing is complete; Safari, mobile, offline, high-traffic, and accessibility testing remain pending. This PR adds no app text, assets, form inputs, new code patterns, or generic components. It does not change how messages are edited or sent. No separate input-error test applies. Testing from links while signed in and signed out, and another manual test after the final merge, have not been completed for this smaller version.

Screenshots/Videos

Earlier recording, before the scope reduction:
https://github.com/user-attachments/assets/4117ea82-2e2c-4d7c-abe6-4c1a2c2151a0

Android: Native

Testing pending.

Android: mWeb Chrome

Testing pending.

iOS: Native

Testing pending.

iOS: mWeb Safari

Testing pending.

MacOS: Chrome / Safari

Chrome: payment, NetSuite export, and ordinary-comment flows verified locally. Updated recording pending.
Safari: testing pending.

@deetergp
deetergp force-pushed the deetergp/677837-hide-read-markers branch from aedf1af to 50b756f Compare September 8, 2026 01:22
…read-markers

# Conflicts:
#	src/hooks/useUnreadMarker.ts
#	src/pages/inbox/report/ReportActionsList.tsx
@codecov

codecov Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/hooks/useUnreadMarker.ts 98.68% <100.00%> (+0.15%) ⬆️
src/libs/ReportActionsUtils.ts 85.61% <100.00%> (+0.02%) ⬆️
src/libs/actions/Report/index.ts 76.09% <100.00%> (+0.05%) ⬆️
...box/report/shouldDisplayNewMarkerOnReportAction.ts 100.00% <100.00%> (+1.58%) ⬆️
...box/report/useReportUnreadMessageScrollTracking.ts 100.00% <100.00%> (ø)
... and 18 files with indirect coverage changes

@deetergp
deetergp marked this pull request as ready for review September 10, 2026 03:26
@deetergp
deetergp requested review from a team as code owners September 10, 2026 03:26
@melvin-bot
melvin-bot Bot requested a review from situchan September 10, 2026 03:26
@melvin-bot

melvin-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

@situchan 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 requested review from garrettmknight and removed request for a team September 10, 2026 03:26
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T03:18:34.299268Z c4f271c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@situchan

situchan commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified any copy / text that was added to the app 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 verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
this.branch.mov

@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: 98d3973177

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/hooks/useUnreadMarker.ts Resolved

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

Very excited for this one!

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

Please check automated review comments.

And can you please attach video to see how this works?

@MelvinBot

This comment has been minimized.

@deetergp

deetergp commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

This PR has gone full Akira with scope creep. I have reined it in and reduced it back to the intent of the original Github issue: Mark paid reports unread for just the submitter of the report (aka, the one who actually needs to be notified that their reimbursement is in their account), and that "Exported to $integration" messages do not get marked unread for anybody.

@deetergp

deetergp commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

@mollfpr All you, I think

@situchan

situchan commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Please pull main to avoid potential Oxfmt failure

@MelvinBot

Copy link
Copy Markdown
Contributor

Review at c4f271c: 1 regression, 1 thing to confirm

The scoped-down version is clean. One predicate, canReportActionTriggerUnreadMarker, now feeds the scan, the lookahead, the offline boundary, and the pagination anchor. The tests cover both list directions and offline. Two things before merge:

🟡 1. LHN "Mark as unread" bolds the row but shows no "New" divider

LHN "Mark as unread" passes no action. So markCommentAsUnread sets lastReadTime to 1 ms before the newest action from another user and leaves the manual anchor null. If that action is a NetSuite export or someone else's reimbursement, the scan now skips it (shouldDisplayNewMarkerOnReportAction.ts:213-219). Nothing older is unread, so no divider appears.

This is situchan's precondition case, which you agreed should work. The fix in 64e3004 was dropped with the scope cut.

Jest repro

Input: the newest other-user action is a NetSuite export (or a reimbursement with actionableForAccountIDs: [otherUser]). unreadMarkerTime is its created minus 1 ms. There is no manual anchor.

Result: getUnreadMarkerReportAction returns [null, -1] for both isReversed values. On main, the same input puts the divider on that action.

Possible narrow fix: in the no-action path of markCommentAsUnread, skip actions that fail canReportActionTriggerUnreadMarker when picking latestReportActionFromOtherUsers. The divider then lands on the newest eligible action (for example, "approved"), and the manual-anchor logic stays untouched. If no eligible action exists, keep today's fallback.

2. Please confirm the bold row on staging (Tests steps 4, 6, and 10)

This PR changes only the divider. The bold LHN row still comes from isUnread, which compares lastReadTime with lastVisibleActionCreated. So "unread for A only" and "the export alone does not make the report unread" depend entirely on the report fields the server sends.

If the server still moves lastVisibleActionCreated forward for a NetSuite export made by another user, that user gets a bold row with no divider. Your NetSuite test used a locally added action. Please run step 10 on staging with a real export made by another user.

Nit

Your latest comment says "Exported to $integration" messages should not show "New" for anybody. The code filters only NetSuite, and the description says other integrations are unchanged. Please confirm that NetSuite-only is what you intend.


view run

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: c4f271c1f8

ℹ️ 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".

@MelvinBot

Copy link
Copy Markdown
Contributor

Regression hunt at c4f271c: 1 new regression, 1 edge case, 1 still open

The branch hasn't changed since my last review. This pass covered the mark-as-read, scroll, and rendering paths. Collapsed system messages, the money-request list (oldest-first), and the "Latest messages" pill all look fine.

🟡 1. New: scrolling down no longer marks the report read after a hidden action arrives

Steps:

  1. Open a report and scroll up more than the threshold.
  2. A NetSuite export, or a reimbursement meant for someone else, arrives.
  3. Scroll back down by hand instead of tapping the pill.

On main: the export gets a divider. When it scrolls into view, the deferred read completes and lastReadTime moves forward.

With this PR: there's no divider, so the read stays deferred. It completes only after you tap the pill, refocus the app, reopen the report, or another action arrives. Until then, the LHN row stays bold if the server counts the report as unread.

Code path
  • Because you're scrolled up, useMarkAsRead.ts:267-283 sets readActionSkippedRef instead of reading.
  • The only scroll-driven way to finish the read is onUnreadActionVisible → completeSkippedMarkAsRead. It is gated on unreadMarkerReportActionIndex !== -1 (useReportUnreadMessageScrollTracking.ts:165-168).
  • The report-change effect re-runs only when lastVisibleActionCreated, visibility, or loaded state change (useMarkAsRead.ts:290-292), so scrolling doesn't re-run it.
  • A Jest repro confirms it. On the PR, the scan returns [null, -1] for a new export while you're scrolled up, and onUnreadActionVisible never fires. The control case with a divider at index 0 does fire it.
  • Your earlier 1ce0048 fixed this case ("completes a deferred mark-as-read when the user scrolls to the end, even without a divider"). That fix was dropped with the scope cut.

Fix: in the scroll tracker, also call onUnreadActionVisible when there's no divider and the list is at the newest end.

🟢 2. Edge case: a late-arriving comment can lose its divider

You're scrolled up or the window is unfocused. A hidden export E (created 12:00) arrives with no divider, so useUnreadMarker.ts:177-179 moves unreadMarkerTime to 12:00. If a real comment created at 11:00 arrives in a later update (for example, after a reconnect), it counts as read and gets no divider. On main, E holds the divider, so the watermark doesn't move. A Jest repro confirms this. It needs out-of-order delivery, so it should be rare.

🟡 3. Still open: LHN "Mark as unread" shows no divider

This is from my last review. It applies when the newest action from another user is a NetSuite export or someone else's reimbursement.


view run

@deetergp
deetergp requested a review from situchan November 4, 2026 02:12
@situchan

situchan commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Please check if this is bug or expected:

"Mark as unread" from LHN shows no divider when the NetSuite export is the only action from another user

  1. Workspace with NetSuite connected and Approvals off. A is the workspace admin, B is a member.
  2. As B, create two expenses on the same report and submit it.
  3. As A, open the report and choose Mark as exported (or Export to NetSuite).
  4. As B, open the report, then switch to another chat.
  5. As B, right-click the report in the LHN and choose Mark as unread.
  6. Open the report.

main: "New" divider above "exported to NetSuite".
this branch: no divider shows.

main.mov
this.branch.mov

As this is non-critical and this PR is now narrowed to NetSuite only, I won't block on this.

@situchan

situchan commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@deetergp please merge main and fix Oxlint

@melvin-bot
melvin-bot Bot requested a review from justinpersaud November 5, 2026 16:35
@melvin-bot

melvin-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

@justinpersaud 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]

@deetergp

Copy link
Copy Markdown
Contributor Author

@situchan Done!

@deetergp

Copy link
Copy Markdown
Contributor Author

@MelvinBot why did you add @justinpersaud? @mollfpr is already the internal reviewer…

@MelvinBot

Copy link
Copy Markdown
Contributor

The melvin-bot[bot] automation requested justinpersaud on November 5, immediately after situchan re-approved—not an action from my AI review.

mollfpr had already reviewed but was no longer a pending reviewer. The automation appears to have mistaken that for needing another internal reviewer; I haven’t verified its selection logic.

You’re right: mollfpr was already handling this, so the additional request was unnecessary. I haven’t changed the reviewers.


view run

@deetergp
deetergp removed the request for review from justinpersaud November 10, 2026 22:07
@deetergp

Copy link
Copy Markdown
Contributor Author

@mollfpr All you!

@deetergp

Copy link
Copy Markdown
Contributor Author

Bump @mollfpr

This branch has not been deployed

No deployments
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.

5 participants