You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$250] Inbox - Marking all as read does not clear unread chats and unread markers #101684
Version Number: 9.4.90-0 Reproducible in staging?: Yes Reproducible in production?: No If this was caught during regression testing, add the test name, ID and link from BrowserStack:#100693 Email or phone of affected tester (no customers):applausetester+bm2244a@applause.expensifail.com Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: android App Component: Left Hand Navigation (LHN)
Action Performed:
Preconditions:
Log in to an account that has unread messages
Go to staging.new.expensify.com
Go to Inbox page, switch to Unread tab
Long-press on Unread tab, select "Mark all as read"
Expected Result:
App should clear all unread chats and unread markers
A. Unread chats aren't cleared — regression from PR #100693
That PR rewrote isEmptyReport() to take the emptiness flag as a parameter, and in doing so changed what an absent value means:
Before (ReportUtils.ts:9695-9707) — read the derived attributes live; if the entry existed, use its isEmpty, even when false.
After (ReportUtils.ts:9689-9694) — derivedIsEmptyReport ?? generateIsEmptyReport(...). If the caller's value is undefined, recompute.
The fallback is not equivalent. generateIsEmptyReport() returns true for any report with no lastMessageText whose actions aren't in memory — the normal state on a freshly launched mobile app. The derived flag is persisted to disk, so it can hold false where a fresh recompute says true.
The same PR also changed wheremarkAllMessagesAsRead gets that data. It used to come from ReportUtils' own live Onyx.connect, independent of React. Now it's a render snapshot captured in InboxTabSelector.tsx:47 and passed down at :101.
When that snapshot is missing or unhydrated, every report fails the isUnread() filter, reportIDList stays empty, and the action returns before API.write — no optimistic write, no network call, no error. Silently nothing happens, which is exactly what the tester saw.
B. Unread markers can't be cleared by this action at all — pre-existing
Even with a successful write, markAllMessagesAsRead cannot remove the in-chat "New" line, for two independent reasons:
unreadMarkerTime is seeded once at mount (useUnreadMarker.ts:82) and only advanced by the unreadAction_* / readNewestAction_*DeviceEventEmitter events. markAllMessagesAsRead emits neither — it only merges lastReadTime.
shouldDisplayNewMarkerOnReportAction.ts:65-66 hard-pins the marker whenever manuallyMarkedUnreadReportActionID is set, ignoring lastReadTime entirely. Only openReport ever clears it; markAllMessagesAsRead never does.
This matters for this exact repro: if the tester created the unread state with "Mark as unread" (the usual way to satisfy the "account with unread messages" precondition), the marker survives even a fully successful mark-all-as-read.
What changes do you think we should make in order to solve the problem?
Make markAllMessagesAsRead read REPORT_ATTRIBUTES live via Onyx.connectWithoutView, matching what UnreadIndicatorUpdater already does, instead of accepting a render snapshot. This restores pre-PR behavior and lets the reportAttributesDerived plumbing come back out of InboxTabSelector and MarkAllMessagesAsReadHandler.
Restore the old contract in isEmptyReport so "no derived entry" is distinguishable from "entry says false". An absent caller value must never silently trigger a recompute that can disagree with the cached flag.
Clear the manual-unread state in markAllMessagesAsRead: include manuallyMarkedUnreadReportActionID: null in the optimistic merge and emit readNewestAction_<reportID> for each marked report, so mounted chats drop the "New" line.
Close the test gap. The only coverage is tests/actions/ReportTest.ts:3592, which calls markAllMessagesAsRead(undefined, undefined, undefined) — it never exercises the derived-isEmpty path. Add a test with REPORT_ATTRIBUTES populated, and one asserting the Unread tab's membership and what the action marks stay in agreement.
What alternative solutions did you explore?
Backend rejection + failureData rollback. There's no successData, and failureData restores the previous lastReadTime for every report, so a rejected MarkAllMessagesAsRead would look identical to "nothing cleared". I could not rule this out — VictoriaLogs was unavailable in this run, so there is no production confirmation of whether the request was sent. One log query settles it: if no MarkAllMessagesAsRead request exists for the tester's session, the client bailed and the diagnosis above is confirmed; if one exists and failed, it's the backend instead.
Frozen LHN snapshot. Ruled out — updateReportsToDisplayInLHN correctly rewrites the entry when unread flags clear (SidebarUtils.ts:404-421), so the optimistic merge is sufficient to clear LHN bolding and the tab badge.
Wrong or misordered arguments in the PR. Ruled out — every changed isUnread() / isEmptyReport() call site was audited and threads the correct value in the correct position.
A different staging-only PR. Ruled out at blob level, see below.
Supporting evidence
Release-window fit is exact. Comparing production 9.4.89-0 against staging 9.4.90-0:
The feature itself already ships in production (InboxTabSelector.tsx exists at 9.4.89-0), so "works in prod, fails in staging" is a real A/B, not a missing feature.
Also verified and ruled out: shape mismatch in useReportAttributes() (it correctly returns .reports); a different archived input in the derived isEmpty computation; partial derived entries missing isEmpty; stale closures in PopoverMenu (byte-identical prod↔staging).
Separate pre-existing asymmetry, worth noting but not the cause here: the Unread tab calls isUnread(report, undefined, ...) while the action passes the one-transaction thread report. Since isUnread takes max(report.lastReadTime, thread.lastReadTime), a one-transaction expense report whose thread was already read looks unread to the tab but read to the action. That's present verbatim in production, and would cause a partial failure, not a total one.
Confidence: high that PR #100693 is the cause (blob-level proof); medium on the precise runtime trigger, which needs the log query above or a device log of reportIDList.length at the call site.
Reproduction note: I attempted to verify on web, but agent-device in this environment supports neither right-click nor long-press, and right-click is the only entry point to this menu on desktop web. The repro was not reproduced first-hand.
The refactor that caused this is being applied repeatedly (this PR is "Phase 4", citing Phase 2's pattern, under refactor issue #66412), so the same hazard can recur in each phase. Proposed for Expensify/App:
Rule:CONSISTENCY-18 — Threading a cached Onyx value into a parameter must not make undefined mean "recompute"
Condition: Flag when a refactor replaces a module-level derived-Onyx read with a caller-passed parameter and the absent case falls back to a recompute (return derivedX ?? computeX(...)). The recompute is rarely equivalent to the persisted cached value. Make the parameter required, or keep the entry-exists check so an absent caller value can't silently flip the result. Separately, flag imperative one-shot actions in src/libs/actions/ that receive derived Onyx data as a React render snapshot instead of reading it live via Onyx.connectWithoutView.
Why: A wrong emptiness answer made isUnread() false for every report, so markAllMessagesAsRead early-returned with no API call and no optimistic write — a completely silent no-op.
Search pattern:return\s+\w*[Dd]erived\w*\s*\?\?\s*(generate|compute|get)\w+\( across src/libs/, plus Derived(Value)?\b appearing in a parameter list under src/libs/actions/.
The full rule file, with the ❌/✅ code inline in the app-coding-standards format, would go in App/.claude/skills/app-coding-standards/rules/. If it's worth adding, a maintainer can open it there as a draft PR.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/101684) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
Reproduced on web. The cause is not a missing isEmpty snapshot. In my run the derived value was present and correct, and a normal unread chat was marked read as expected.
What gets stuck is a one-expense report whose expense (thread) was already read. The Unread tab checks it without the thread, so it's listed as unread:
No API call and no optimistic update. The report stays in the Unread tab until it's opened.
Fix: pass the one-transaction thread to getIsUnreadReportForInboxTab, so the tab, the LHN bold state and the action use the same check. In both getReportsToDisplayInLHN and updateReportsToDisplayInLHN:
Please re-state the problem that we are trying to solve in this issue.
When using the "Mark all as read" action on the Inbox > Unread tab, certain one-expense reports remain stuck in the Unread tab with bold unread markers and do not clear until manually opened.
What is the root cause of that problem?
There is a discrepancy in how unread state is calculated between the Inbox tab filter and the MarkAllMessageAsRead action:
In src/libs/SidebarUtils.ts:987-995, getIsUnreadReportForInboxTab checks whether a report should appear in the "Unread" tab by calling isUnread with undefined for oneTransactionThreadReport:
Because oneTransactionThreadReport is undefined, for a one-expense report whose expense thread was already read, isUnread falls back to evaluating the parent report in isolation and returns true. Consequently, isUnreadReport is set to true, and the report is displayed in the "Unread" tab.
In src/libs/actions/Report/MarkAllMessageAsRead.tsx:67, markAllMessagesAsRead checks whether the report needs to be marked read with the thread report:
isUnread(report,oneTransactionThreadReport)
Because the one-transaction thread is already read, isUnread evaluates to false.
As a result, MarkAllMessageAsRead determines that the report is already read and excludes it from the reportIDList payload. No optimistic update and no API call are made. The report remains permanently trapped in the Unread tab until opened.
What changes do you think we should make in order to solve the problem?
Pass the oneTransactionThreadReport to getIsUnreadReportForInboxTab so that the Unread tab, the LHN bold indicator, and MarkAllMessageAsRead all use the identical, unified unread check.
1. In src/libs/SidebarUtils.ts:
Update getIsUnreadReportForInboxTab to accept oneTransactionThreadReport:
Assert the report does not appear in CONST.INBOX_TAB.UNREAD.
One-transaction expense report where thread is unread:
Given a one-transaction expense report with an unread oneTransactionThreadReport.
Assert getIsUnreadReportForInboxTab returns true.
Execute markAllMessagesAsRead and assert report is included and unread state clears.
What alternative solutions did you explore? (Optional)
Removing oneTransactionThreadReport from MarkAllMessageAsRead:
Rejected because MarkAllMessageAsRead's check is the correct business logic (an expense report whose single transaction thread has been read should not be treated as unread). Aligning SidebarUtils ensures consistent UI behavior across the entire app.
📣 @stacklancer You have been assigned to this job!
Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻
Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs!
Keep in mind: Code of Conduct | Contributing 📖
I tested it on web (Chrome on Windows), in a phone-width Chrome window, and offline. Screenshots are in the PR. I couldn't run the iOS/Android native builds on my machine, so those aren't covered yet. Happy to fix anything you find.
Update: PR #105176 is ready for review. I addressed the Codex review (fixed the To-do tab case and the Shift+Esc shortcut, with tests). @eVoloshchak whenever you get a chance.
Activity
applause-bot commentedon Sep 21, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/c329b51fb7afe7ab201e84c73e9afdd567d11ca1817f62d37f25bb746871e11f
MelvinBot commentedon Sep 21, 2026
Proposal
This is two separate defects that together produce the reported symptom. "Unread chats not cleared" is a regression from [Phase 4] - Remove module-level reportAttributesDerivedValue in isEmptyReport(). "Unread markers not cleared" is a pre-existing gap that PR QA surfaced for the first time.
What is the root cause of that problem?
A. Unread chats aren't cleared — regression from PR #100693
That PR rewrote
isEmptyReport()to take the emptiness flag as a parameter, and in doing so changed what an absent value means:ReportUtils.ts:9695-9707) — read the derived attributes live; if the entry existed, use itsisEmpty, even whenfalse.ReportUtils.ts:9689-9694) —derivedIsEmptyReport ?? generateIsEmptyReport(...). If the caller's value isundefined, recompute.The fallback is not equivalent.
generateIsEmptyReport()returnstruefor any report with nolastMessageTextwhose actions aren't in memory — the normal state on a freshly launched mobile app. The derived flag is persisted to disk, so it can holdfalsewhere a fresh recompute saystrue.The same PR also changed where
markAllMessagesAsReadgets that data. It used to come from ReportUtils' own liveOnyx.connect, independent of React. Now it's a render snapshot captured inInboxTabSelector.tsx:47and passed down at:101.When that snapshot is missing or unhydrated, every report fails the
isUnread()filter,reportIDListstays empty, and the action returns beforeAPI.write— no optimistic write, no network call, no error. Silently nothing happens, which is exactly what the tester saw.Note the same PR kept the live read in
UnreadIndicatorUpdater/index.ts:68-75. So the badge and the action can now disagree about what's unread.B. Unread markers can't be cleared by this action at all — pre-existing
Even with a successful write,
markAllMessagesAsReadcannot remove the in-chat "New" line, for two independent reasons:unreadMarkerTimeis seeded once at mount (useUnreadMarker.ts:82) and only advanced by theunreadAction_*/readNewestAction_*DeviceEventEmitterevents.markAllMessagesAsReademits neither — it only mergeslastReadTime.shouldDisplayNewMarkerOnReportAction.ts:65-66hard-pins the marker whenevermanuallyMarkedUnreadReportActionIDis set, ignoringlastReadTimeentirely. OnlyopenReportever clears it;markAllMessagesAsReadnever does.This matters for this exact repro: if the tester created the unread state with "Mark as unread" (the usual way to satisfy the "account with unread messages" precondition), the marker survives even a fully successful mark-all-as-read.
What changes do you think we should make in order to solve the problem?
markAllMessagesAsReadreadREPORT_ATTRIBUTESlive viaOnyx.connectWithoutView, matching whatUnreadIndicatorUpdateralready does, instead of accepting a render snapshot. This restores pre-PR behavior and lets thereportAttributesDerivedplumbing come back out ofInboxTabSelectorandMarkAllMessagesAsReadHandler.isEmptyReportso "no derived entry" is distinguishable from "entry saysfalse". An absent caller value must never silently trigger a recompute that can disagree with the cached flag.markAllMessagesAsRead: includemanuallyMarkedUnreadReportActionID: nullin the optimistic merge and emitreadNewestAction_<reportID>for each marked report, so mounted chats drop the "New" line.tests/actions/ReportTest.ts:3592, which callsmarkAllMessagesAsRead(undefined, undefined, undefined)— it never exercises the derived-isEmptypath. Add a test withREPORT_ATTRIBUTESpopulated, and one asserting the Unread tab's membership and what the action marks stay in agreement.What alternative solutions did you explore?
failureDatarollback. There's nosuccessData, andfailureDatarestores the previouslastReadTimefor every report, so a rejectedMarkAllMessagesAsReadwould look identical to "nothing cleared". I could not rule this out — VictoriaLogs was unavailable in this run, so there is no production confirmation of whether the request was sent. One log query settles it: if noMarkAllMessagesAsReadrequest exists for the tester's session, the client bailed and the diagnosis above is confirmed; if one exists and failed, it's the backend instead.updateReportsToDisplayInLHNcorrectly rewrites the entry when unread flags clear (SidebarUtils.ts:404-421), so the optimistic merge is sufficient to clear LHN bolding and the tab badge.isUnread()/isEmptyReport()call site was audited and threads the correct value in the correct position.Supporting evidence
Release-window fit is exact. Comparing production
9.4.89-0against staging9.4.90-0:src/libs/actions/Report/MarkAllMessageAsRead.tsx— prod blob544edd0511b9(PR pre-image) → staging blob2d766d52f1f8(PR post-image). PR [Phase 4] - Remove module-level reportAttributesDerivedValue in isEmptyReport() #100693 is the only change to this file between the two.src/hooks/useSidebarOrderedReports.tsxandsrc/libs/actions/OnyxDerived/configs/reportAttributes.ts— blobs identical prod↔staging.src/libs/ReportUtils.tsprod→staging patch, filtered toisUnread|isEmptyReport|lastReadTime, contains only PR [Phase 4] - Remove module-level reportAttributesDerivedValue in isEmptyReport() #100693's hunks.InboxTabSelector.tsxexists at9.4.89-0), so "works in prod, fails in staging" is a real A/B, not a missing feature.Also verified and ruled out: shape mismatch in
useReportAttributes()(it correctly returns.reports); a different archived input in the derivedisEmptycomputation; partial derived entries missingisEmpty; stale closures inPopoverMenu(byte-identical prod↔staging).Separate pre-existing asymmetry, worth noting but not the cause here: the Unread tab calls
isUnread(report, undefined, ...)while the action passes the one-transaction thread report. SinceisUnreadtakesmax(report.lastReadTime, thread.lastReadTime), a one-transaction expense report whose thread was already read looks unread to the tab but read to the action. That's present verbatim in production, and would cause a partial failure, not a total one.Confidence: high that PR #100693 is the cause (blob-level proof); medium on the precise runtime trigger, which needs the log query above or a device log of
reportIDList.lengthat the call site.Reproduction note: I attempted to verify on web, but
agent-devicein this environment supports neither right-click nor long-press, and right-click is the only entry point to this menu on desktop web. The repro was not reproduced first-hand.Related issues
💡 Suggested AI code review rule
The refactor that caused this is being applied repeatedly (this PR is "Phase 4", citing Phase 2's pattern, under refactor issue #66412), so the same hazard can recur in each phase. Proposed for
Expensify/App:CONSISTENCY-18— Threading a cached Onyx value into a parameter must not makeundefinedmean "recompute"return derivedX ?? computeX(...)). The recompute is rarely equivalent to the persisted cached value. Make the parameter required, or keep the entry-exists check so an absent caller value can't silently flip the result. Separately, flag imperative one-shot actions insrc/libs/actions/that receive derived Onyx data as a React render snapshot instead of reading it live viaOnyx.connectWithoutView.isUnread()false for every report, somarkAllMessagesAsReadearly-returned with no API call and no optimistic write — a completely silent no-op.return\s+\w*[Dd]erived\w*\s*\?\?\s*(generate|compute|get)\w+\(acrosssrc/libs/, plusDerived(Value)?\bappearing in a parameter list undersrc/libs/actions/.src/libs/ReportUtils.ts:9689-9694src/libs/ReportUtils.ts:9695-9707as it was before the PRThe full rule file, with the ❌/✅ code inline in the
app-coding-standardsformat, would go inApp/.claude/skills/app-coding-standards/rules/. If it's worth adding, a maintainer can open it there as a draft PR.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/101684)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run · no recording available
melvin-bot commentedon Sep 21, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @eVoloshchak (
External)melvin-bot commentedon Sep 21, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
melvin-bot commentedon Sep 24, 2026
@eVoloshchak Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
M00rish commentedon Sep 25, 2026
Reproduced on web. The cause is not a missing
isEmptysnapshot. In my run the derived value was present and correct, and a normal unread chat was marked read as expected.What gets stuck is a one-expense report whose expense (thread) was already read. The Unread tab checks it without the thread, so it's listed as unread:
App/src/libs/SidebarUtils.ts
Line 991 in e029fad
The action checks it with the thread, so it's treated as read and skipped:
App/src/libs/actions/Report/MarkAllMessageAsRead.tsx
Line 67 in e029fad
Values logged inside the action for a report the Unread tab was showing:
No API call and no optimistic update. The report stays in the Unread tab until it's opened.
Fix: pass the one-transaction thread to
getIsUnreadReportForInboxTab, so the tab, the LHN bold state and the action use the same check. In bothgetReportsToDisplayInLHNandupdateReportsToDisplayInLHN:and pass it through to
isUnreadingetIsUnreadReportForInboxTab. I tested this locally: with the same state, the Unread tab shows "No unread chats".ashusatyarthi-wq commentedon Sep 27, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When using the "Mark all as read" action on the Inbox > Unread tab, certain one-expense reports remain stuck in the Unread tab with bold unread markers and do not clear until manually opened.
What is the root cause of that problem?
There is a discrepancy in how unread state is calculated between the Inbox tab filter and the
MarkAllMessageAsReadaction:src/libs/SidebarUtils.ts:987-995,getIsUnreadReportForInboxTabchecks whether a report should appear in the "Unread" tab by callingisUnreadwithundefinedforoneTransactionThreadReport:Because
oneTransactionThreadReportisundefined, for a one-expense report whose expense thread was already read,isUnreadfalls back to evaluating the parent report in isolation and returnstrue. Consequently,isUnreadReportis set totrue, and the report is displayed in the "Unread" tab.src/libs/actions/Report/MarkAllMessageAsRead.tsx:67,markAllMessagesAsReadchecks whether the report needs to be marked read with the thread report:Because the one-transaction thread is already read,
isUnreadevaluates tofalse.MarkAllMessageAsReaddetermines that the report is already read and excludes it from thereportIDListpayload. No optimistic update and no API call are made. The report remains permanently trapped in the Unread tab until opened.What changes do you think we should make in order to solve the problem?
Pass the
oneTransactionThreadReporttogetIsUnreadReportForInboxTabso that the Unread tab, the LHN bold indicator, andMarkAllMessageAsReadall use the identical, unified unread check.1. In
src/libs/SidebarUtils.ts:Update
getIsUnreadReportForInboxTabto acceptoneTransactionThreadReport:2. Pass
oneTransactionThreadReportat call sites inSidebarUtils.ts:In both
getReportsToDisplayInLHN(line 316) andupdateReportsToDisplayInLHN(line 405):What specific scenarios should be covered in tests?
Add unit tests in
tests/unit/SidebarUtilsTest.ts:oneTransactionThreadReportwhoselastReadTime >= lastVisibleActionCreated.getIsUnreadReportForInboxTabreturnsfalse.CONST.INBOX_TAB.UNREAD.oneTransactionThreadReport.getIsUnreadReportForInboxTabreturnstrue.markAllMessagesAsReadand assert report is included and unread state clears.What alternative solutions did you explore? (Optional)
oneTransactionThreadReportfromMarkAllMessageAsRead:MarkAllMessageAsRead's check is the correct business logic (an expense report whose single transaction thread has been read should not be treated as unread). AligningSidebarUtilsensures consistent UI behavior across the entire app.melvin-bot commentedon Sep 28, 2026
@eVoloshchak Still overdue 6 days?! Let's take care of this!
melvin-bot commentedon Sep 30, 2026
@eVoloshchak 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!
110 remaining items
melvin-bot commentedon Oct 26, 2026
Triggered auto assignment to @justinpersaud, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
melvin-bot commentedon Oct 26, 2026
📣 @stacklancer You have been assigned to this job!
Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻
Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs!
Keep in mind: Code of Conduct | Contributing 📖
stacklancer commentedon Oct 27, 2026
Thanks @eVoloshchak! I've applied on Upwork. I'll update the branch to latest main and open the PR within 24 hours.
stacklancer commentedon Oct 27, 2026
@eVoloshchak the PR is up: #105176
I tested it on web (Chrome on Windows), in a phone-width Chrome window, and offline. Screenshots are in the PR. I couldn't run the iOS/Android native builds on my machine, so those aren't covered yet. Happy to fix anything you find.
stacklancer commentedon Oct 28, 2026
Update: PR #105176 is ready for review. I addressed the Codex review (fixed the To-do tab case and the Shift+Esc shortcut, with tests). @eVoloshchak whenever you get a chance.
jeffrey-graham commentedon Nov 7, 2026
melvin-bot commentedon Nov 7, 2026
expensify-chore-bot commentedon Nov 18, 2026
@stacklancer Still overdue 6 days?! Let's take care of this!