[$250] Inbox - Marking all as read does not clear unread chats and unread markers
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: 9.4.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: https://github.com/Expensify/App/pull/100693 Email or phone of affected tester (no customers): [email protected] 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
Actual Result:
Unread chats and unread markers are not cleared
Workaround:
Unknown
Platforms:
- [x] Android: App
- [ ] Android: mWeb Chrome
- [ ] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [ ] MacOS: Chrome Safari
Screenshots/Videos
https://github.com/user-attachments/assets/b2f18588-54c3-43ff-9a28-1f174d04deb0
Applause Internal Information Exported by: Rizky Gunawan Bug ID: 7263667
Issue Owner
Current Issue Owner: @stacklancerUpwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022106030737448785107
- Upwork Job ID: 2106030737448785107
- Last Price Increase: 2026-10-23
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
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:
- Before (
ReportUtils.ts:9695-9707) — read the derived attributes live; if the entry existed, use itsisEmpty, even whenfalse. - After (
ReportUtils.ts:9689-9694) —derivedIsEmptyReport ?? generateIsEmptyReport(...). If the caller's value isundefined, 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 where markAllMessagesAsRead 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.
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, markAllMessagesAsRead cannot 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?
- Make
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. - Restore the old contract in
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. - Clear the manual-unread state in
markAllMessagesAsRead: includemanuallyMarkedUnreadReportActionID: nullin the optimistic merge and emitreadNewestAction_<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 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?
- Backend rejection +
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. - Frozen LHN snapshot. Ruled out —
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. - 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:
src/libs/actions/Report/MarkAllMessageAsRead.tsx— prod blob544edd0511b9(PR pre-image) → staging blob2d766d52f1f8(PR post-image). PR #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 #100693's hunks.- The feature itself already ships in production (
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 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.
Related issues
- [Due for payment 2026-09-17] Extend right-click "Mark all as read" to all Inbox tabs — the feature that introduced this entry point.
- Marking a chat as unread doesn't stick — client immediately re-reads it, and other clients never see the change — same unread-state subsystem, possibly related.
- [Due for payment 2026-09-25] [$250] Chat - The new message marker isn't displayed when user marks their own message as unread — touches the same "New" marker logic as defect B.
💡 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:
- Rule:
CONSISTENCY-18— Threading a cached Onyx value into a parameter must not makeundefinedmean "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 insrc/libs/actions/that receive derived Onyx data as a React render snapshot instead of reading it live viaOnyx.connectWithoutView. - Why: A wrong emptiness answer made
isUnread()false for every report, somarkAllMessagesAsReadearly-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+\(acrosssrc/libs/, plusDerived(Value)?\bappearing in a parameter list undersrc/libs/actions/. - Offending code (❌):
src/libs/ReportUtils.ts:9689-9694 - Fix (✅):
src/libs/ReportUtils.ts:9695-9707as it was before the PR
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.
view run · no recording available
Triggered auto assignment to Contributor-plus team member for initial proposal review - @eVoloshchak (External)
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
@eVoloshchak Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
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: https://github.com/Expensify/App/blob/e029fad955164435583153ee7f862942711273cb/src/libs/SidebarUtils.ts#L991
The action checks it with the thread, so it's treated as read and skipped: https://github.com/Expensify/App/blob/e029fad955164435583153ee7f862942711273cb/src/libs/actions/Report/MarkAllMessageAsRead.tsx#L67
Values logged inside the action for a report the Unread tab was showing:
6133559146143422 {"derived":{"isEmpty":false,"oneTransactionThreadReportID":"2055341732240261"},"unread":false}
reportIDList []
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:
const oneTransactionThreadReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportAttributes?.[report?.reportID]?.oneTransactionThreadReportID}`];
const isUnreadReport = getIsUnreadReportForInboxTab(report, oneTransactionThreadReport, isReportArchived, reportAttributes?.[report?.reportID]?.isEmpty);
and pass it through to isUnread in getIsUnreadReportForInboxTab. I tested this locally: with the same state, the Unread tab shows "No unread chats".
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 MarkAllMessageAsRead action:
- In
src/libs/SidebarUtils.ts:987-995,getIsUnreadReportForInboxTabchecks whether a report should appear in the "Unread" tab by callingisUnreadwithundefinedforoneTransactionThreadReport:
function getIsUnreadReportForInboxTab(report: Report, isReportArchived: boolean, derivedIsEmptyReport: boolean | undefined): boolean {
return (
isUnread(report, undefined, isReportArchived, derivedIsEmptyReport) &&
!!report.lastActorAccountID &&
getReportNotificationPreference(report) !== CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE
);
}
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,markAllMessagesAsReadchecks 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,
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 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:
-function getIsUnreadReportForInboxTab(report: Report, isReportArchived: boolean, derivedIsEmptyReport: boolean | undefined): boolean {
+function getIsUnreadReportForInboxTab(
+ report: Report,
+ oneTransactionThreadReport: OnyxEntry<Report>,
+ isReportArchived: boolean,
+ derivedIsEmptyReport: boolean | undefined,
+): boolean {
return (
- isUnread(report, undefined, isReportArchived, derivedIsEmptyReport) &&
+ isUnread(report, oneTransactionThreadReport, isReportArchived, derivedIsEmptyReport) &&
!!report.lastActorAccountID &&
getReportNotificationPreference(report) !== CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE
);
}
2. Pass oneTransactionThreadReport at call sites in SidebarUtils.ts:
In both getReportsToDisplayInLHN (line 316) and updateReportsToDisplayInLHN (line 405):
+const oneTransactionThreadReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportAttributes?.[report?.reportID]?.oneTransactionThreadReportID}`];
const isUnreadReport = getIsUnreadReportForInboxTab(
report,
+ oneTransactionThreadReport,
isReportArchived,
reportAttributes?.[report?.reportID]?.isEmpty,
);
What specific scenarios should be covered in tests?
Add unit tests in tests/unit/SidebarUtilsTest.ts:
- One-transaction expense report where thread is read:
- Given a one-transaction expense report with an associated
oneTransactionThreadReportwhoselastReadTime >= lastVisibleActionCreated. - Assert
getIsUnreadReportForInboxTabreturnsfalse. - Assert the report does not appear in
CONST.INBOX_TAB.UNREAD.
- Given a one-transaction expense report with an associated
- One-transaction expense report where thread is unread:
- Given a one-transaction expense report with an unread
oneTransactionThreadReport. - Assert
getIsUnreadReportForInboxTabreturnstrue. - Execute
markAllMessagesAsReadand assert report is included and unread state clears.
- Given a one-transaction expense report with an unread
What alternative solutions did you explore? (Optional)
- Removing
oneTransactionThreadReportfromMarkAllMessageAsRead:- 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). AligningSidebarUtilsensures consistent UI behavior across the entire app.
- Rejected because
@eVoloshchak Still overdue 6 days?! Let's take care of this!
@eVoloshchak 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!
A. Unread chats aren't cleared — regression from https://github.com/Expensify/App/pull/100693 B. Unread markers can't be cleared by this action at all — pre-existing
Cannot 100% verify the (A), but since this is at least partially pre-existing, let's handle it here
I don't think we should restore pre-PR behavior as Melving suggests, opening this to contributors
@MelvinBot, open this to external contributors please
🚨 Edited by proposal-police: This proposal was edited at 2026-10-11 12:43:52 UTC.
Proposal
Updated 2026-10-11. What changed since my 10-02 version:
- The server evidence in this thread now conflicts, and I say so. On 10-02 I captured
400 Invalid lastReadTime, cannot be in the futurefromMarkAllMessagesAsRead. Two later comments report a 200 with the time clamped (dev web, 10-02; staging, 10-09), and QA could not reproduce on 10-10. I can't re-run the API check today, so I can't tell you which behaviour the backend has now. The fix below is correct under both.- Part B (the in-chat "New" marker) is now covered. My first version left it out; @eVoloshchak asked for it to be handled here.
- One hole in my own fix is closed (the user's own pending message could feed a device-clock time back into the request).
- Rewritten against
09f662a, with the patch written and tested.
What is the root cause of that problem?
A. Unread chats come back. In the reporter's video the Unread list empties and the badge clears at 0:07.6, and about 150 ms later all three chats and the "3" return. That is markAllMessagesAsRead's optimistic update being undone by its failureData: the request was sent and it failed.
The one value in that request the client invents is lastReadTime, and it is the device clock:
https://github.com/Expensify/App/blob/09f662acc2306467fe3fbfb648ed90ae107863b1/src/libs/actions/Report/MarkAllMessageAsRead.tsx#L47
https://github.com/Expensify/App/blob/09f662acc2306467fe3fbfb648ed90ae107863b1/src/libs/actions/Report/MarkAllMessageAsRead.tsx#L97-L102
getDBTimeWithSkew() only corrects a clock that is behind the server; a clock that is ahead is sent as-is:
https://github.com/Expensify/App/blob/09f662acc2306467fe3fbfb648ed90ae107863b1/src/libs/NetworkState.ts#L257-L263
What I observed on 10-02 (staging web, browser clock 15 minutes fast): the request went out with a lastReadTime 15 minutes ahead of real time, the response was {"jsonCode":400,"message":"400 Invalid lastReadTime, cannot be in the future"}, and the tab emptied and refilled exactly like the video. With a correct clock the same flow returned 200. As noted above, others have since seen the server clamp instead of reject. Either way the client is sending a time it has no way to know is valid.
B. The "New" marker in an open chat stays. A mounted chat seeds its marker watermark once and afterwards only moves it on two events:
https://github.com/Expensify/App/blob/09f662acc2306467fe3fbfb648ed90ae107863b1/src/hooks/useUnreadMarker.ts#L82-L100
The single-chat "Mark as read" emits one of them:
https://github.com/Expensify/App/blob/09f662acc2306467fe3fbfb648ed90ae107863b1/src/libs/actions/Report/index.ts#L3264-L3266
markAllMessagesAsRead emits neither, so the chat that is open next to the LHN keeps its "New" line even when the write succeeds.
What changes do you think we should make in order to solve the problem?
All in MarkAllMessageAsRead.tsx.
1. Send a time the server produced, not the device clock. While looping over the unread reports, keep the newest server-stamped time among them and use it for both the optimistic data and the API parameter:
// per unread report: the earliest lastReadTime that makes isUnread() false, from server-stamped fields only
newestServerStampedTime = max(newestServerStampedTime, getServerStampedReadTime(report, oneTransactionThreadReport, ...))
// after the loop
const newLastReadTime = newestServerStampedTime || getDBTimeWithSkew();
For an unread report that time is the newer of lastVisibleActionCreated and lastMentionedTime, the same two fields isUnread() compares against, so every marked report turns read. It can't be ahead of the server whatever the device clock says, and it keeps what #100002 wanted: a message that arrives after the click is newer than it and stays unread.
2. Don't let the user's own pending message leak a device time back in. lastVisibleActionCreated is device-stamped while the user's own message is still optimistic. Such a report is only unread through a mention (isUnread ignores the user's own last action), so getServerStampedReadTime tries lastMentionedTime first and uses it whenever isUnread({...report, lastReadTime: lastMentionedTime}) is already false. It reuses isUnread as the check, so the two can't drift.
3. Tell mounted chats. After the write, emit readNewestAction_<reportID> with that same time for each marked report, as the single "Mark as read" does.
The time matters here too. If the event carries a device-clock value that is ahead of the server, the open chat's watermark sits in the future and a message that arrives next gets no "New" line at all. With a server-stamped time that can't happen.
I leave manuallyMarkedUnreadReportActionID alone. The single "Mark as read" does the same on purpose (comment; the clearing was reverted in review on #95217: "keep marker on explicit Mark as read"). If you'd rather "Mark all as read" also drop a manual anchor, it's one extra field in the optimistic and failure data.
Verification. Patch written against 09f662a. In tests/actions/ReportTest.ts I added four tests; three fail on unpatched source and pass with the patch:
- with the device 10 minutes ahead, the request carries the newest server time of the marked reports (including a mention newer than the last message), and both reports read as read;
- a report unread only by a mention, whose last action is the user's own message stamped 5 minutes in the future, sends the mention time;
readNewestAction_<reportID>is emitted with that time, a message stamped after it still counts as unread, and a manual anchor is untouched.
The fourth pins the existing rollback on failure. ReportTest, SidebarUtilsTest, UnreadIndicatorUpdaterTest, BaseSidebarScreenTest: 457/457 with the patch. Typecheck is clean for the touched files.
What I did not verify: today's server response (see the update note), and the flow on a device.
What alternative solutions did you explore? (Optional)
getServerAnchoredDBTime(). On web the skew is never measured (theDateheader isn't readable cross-origin, so it ends up assetTimeSkew(0)), so web behaves exactly as today. On native the header has 1-second resolution. It narrows the window; it doesn't close it.- Subtract a fixed margin from the device time. A clock faster than the margin still fails, and with an accurate clock the last few seconds of messages silently stay unread.
- Make
useUnreadMarkerfollow everylastReadTimechange instead of emitting an event. Rejected:readNewestActiondeliberately advanceslastReadTimewithout moving the marker, so the user keeps the "New" line while reading. - Clamp on the backend. If it now does, good, but the App shouldn't depend on it, and the marker problem in step 3 exists either way.
Known limits, so nobody is surprised in review:
- If no marked report has any timestamp at all, the fallback is still the device clock. I haven't found a real report in that state.
- One
lastReadTimecovers the whole batch (the API takes one). It is the newest message the client knows about, so it is never looser than the "now" we send today. - If the write fails, Onyx restores
lastReadTimebut a mounted chat's "New" line doesn't come back until the chat is reopened. The single "Mark as read" has the same behaviour today. - A one-expense report whose thread is already read can be listed in the Unread tab and skipped by the action. That is a separate, pre-existing mismatch, already described by others above; this change doesn't touch it.
🚨 Edited by proposal-police: This proposal was edited at 2026-10-02 14:47:42 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Android, "Mark all as read" on the Unread tab looks like it does nothing. The chats and the unread badge stay, even though the phone clock is correct.
What is the root cause of that problem?
The action is not a no-op. It runs and then gets rolled back. If you step through the reporter's video at 30fps, right after tapping "Mark all as read" the Unread list empties, the badge goes away and the "No unread chats" confetti shows (~0:07.6). A few frames later all 3 chats and the "3" come back. That only happens if the optimistic data was applied and then the failureData was applied:
https://github.com/Expensify/App/blob/ba7c8b46bee49316fdbf204fda147ea1b75e6f5d/src/libs/actions/Report/MarkAllMessageAsRead.tsx#L89-L102
So the request was sent and the server rejected it. Since #100002 the request carries a client-made lastReadTime, and that value comes from getDBTimeWithSkew():
https://github.com/Expensify/App/blob/ba7c8b46bee49316fdbf204fda147ea1b75e6f5d/src/libs/actions/Report/MarkAllMessageAsRead.tsx#L47
https://github.com/Expensify/App/blob/ba7c8b46bee49316fdbf204fda147ea1b75e6f5d/src/libs/NetworkState.ts#L257-L263
The backend rejects any lastReadTime that is ahead of its own clock (400 Invalid lastReadTime, cannot be in the future), and the whole batch fails.
Why the time is ahead on Android when the device clock is fine: on native, networkTimeSkew is measured from the Date header of OpenApp / ReconnectApp / OpenReport, and the formula counts the round trip twice:
https://github.com/Expensify/App/blob/ba7c8b46bee49316fdbf204fda147ea1b75e6f5d/src/libs/HttpUtils.ts#L132-L139
const latency = (endTime - startTime) / 2;
const skew = serverTime - startTime + latency;
serverTime is stamped when the server finishes the request, so with two perfectly synced clocks serverTime - startTime is already uplink + server processing. Adding latency on top gives roughly 1.5x the round trip, when the real skew is 0. These commands are heavy. If ReconnectApp takes 2s, the skew comes out around +2 to +3s (minus up to 1s because the Date header is truncated to seconds). getDBTimeWithSkew() applies any positive skew, so every MarkAllMessagesAsRead from that session sends a lastReadTime a couple of seconds in the future and gets the 400.
This also explains "not reproducible in production". 9.4.89-0 already has #100002, so it doesn't depend on the build. It depends on how slow the last skew-measuring request was in that session. On web the Date header isn't readable cross-origin so the skew is 0 there, and it only fails when the computer clock itself is fast.
The in-chat marker is a second, smaller gap. Even when the write succeeds, a chat that was manually marked unread keeps its "New" line, because the marker is pinned by manuallyMarkedUnreadReportActionID and the action never clears it:
https://github.com/Expensify/App/blob/ba7c8b46bee49316fdbf204fda147ea1b75e6f5d/src/pages/inbox/report/shouldDisplayNewMarkerOnReportAction.ts#L65-L66
What changes do you think we should make in order to solve the problem?
Stop sending the client clock as the read watermark. In markAllMessagesAsRead, while looping over the reports we are marking, keep the newest server-stamped time we have for them (lastVisibleActionCreated incl. the one-transaction thread, and lastMentionedTime). Send that as lastReadTime and use the same value optimistically:
let newestServerTime = '';
// inside the loop, for each report that isUnread
for (const serverTime of [getReportLastVisibleActionCreated(report, oneTransactionThreadReport), report.lastMentionedTime ?? '']) {
if (serverTime > newestServerTime) {
newestServerTime = serverTime;
}
}
// after the loop
const newLastReadTime = newestServerTime || getDBTimeWithSkew();
optimisticReports[reportKey] = {lastReadTime: newLastReadTime, manuallyMarkedUnreadReportActionID: null};
failureReports[reportKey] = {lastReadTime: report.lastReadTime ?? null, manuallyMarkedUnreadReportActionID: report.manuallyMarkedUnreadReportActionID ?? null};
Those times were all stamped by the server, so the value can never be ahead of the server clock, whatever the skew or the device clock says. It is also >= everything isUnread() compares against, so every marked report still becomes read:
https://github.com/Expensify/App/blob/ba7c8b46bee49316fdbf204fda147ea1b75e6f5d/src/libs/ReportUtils.ts#L10021-L10029
It keeps what #100002 was added for: a message that arrives after the tap is newer than this value, so it stays unread. Clearing manuallyMarkedUnreadReportActionID (and restoring it in failureData) removes the pinned "New" line.
As a follow-up I'd also fix the skew formula to serverTime - endTime. The Date header is always generated before the response arrives, so that is a lower bound and can never land ahead of the server. It touches every optimistic timestamp in the app though, so I'd keep it separate from this bug.
Test branch: https://github.com/Expensify/App/compare/main...dilshodmackbook-sketch:App:fix/101684-mark-all-read-skew
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
In tests/actions/ReportTest.ts (both are on the branch, they fail on main and pass with the fix, all 324 tests in the file pass):
timeSkewset to +10 min and two unread reports, one with a newer mention. AssertMarkAllMessagesAsReadis sent withlastReadTimeequal to the newest server time (not the skewed clock) and both reports read as read.- A report with
manuallyMarkedUnreadReportActionIDset. Assert it is cleared andlastReadTimemoves to the report's last action.
What alternative solutions did you explore? (Optional)
- Use
getServerAnchoredDBTime(). It still uses the same inflated skew on native, and on web the skew is 0, so it doesn't fix either platform. - Subtract a fixed margin from the client time. A skew bigger than the margin still fails, and with a correct clock the last few seconds of messages would silently stay unread.
- Read
REPORT_ATTRIBUTESlive in the action (restore the pre-#100693 read). The video shows the optimistic update was applied, soreportIDListwasn't empty and this path isn't what breaks here. - Clamp
lastReadTimetonowon the backend instead of returning 400. Good hardening, but it's outside this repo and the App fix doesn't need it.
Proposal
What is the root cause of that problem?
I found two state mismatches.
First, markAllMessagesAsRead() decides which reports to update by calling isUnread() for every report:
https://github.com/Expensify/App/blob/2d262c853a8ea8404c3ee33f73f80f236e278f71/src/libs/actions/Report/MarkAllMessageAsRead.tsx#L53-L74
isUnread() rejects reports that isEmptyReport() considers empty:
https://github.com/Expensify/App/blob/2d262c853a8ea8404c3ee33f73f80f236e278f71/src/libs/ReportUtils.ts#L9731-L9743
Before the regression, isEmptyReport() read the persisted derived attribute and only recalculated when that entry was absent:
https://github.com/Expensify/App/blob/2d262c853a8ea8404c3ee33f73f80f236e278f71/src/libs/ReportUtils.ts#L9617-L9633
PR #100693 moved this value into caller-provided data. On mobile, that render snapshot can still be unavailable when the action runs. The fallback calculation then depends on locally loaded report actions. If those actions have not been hydrated, a real chat is classified as empty, excluded from reportIDList, and the action can return without an optimistic update or API request.
Second, the action only changes lastReadTime:
https://github.com/Expensify/App/blob/2d262c853a8ea8404c3ee33f73f80f236e278f71/src/libs/actions/Report/MarkAllMessageAsRead.tsx#L67-L98
That does not reset the in-chat unread marker. useUnreadMarker() initializes its own watermark once and thereafter advances it only through device events:
https://github.com/Expensify/App/blob/2d262c853a8ea8404c3ee33f73f80f236e278f71/src/hooks/useUnreadMarker.ts#L72-L100
A manually marked unread action also overrides the timestamp calculation and remains the marker anchor until its ID is cleared:
https://github.com/Expensify/App/blob/2d262c853a8ea8404c3ee33f73f80f236e278f71/src/pages/inbox/report/shouldDisplayNewMarkerOnReportAction.ts#L55-L67
Therefore a successful bulk read can still leave the existing “New” marker visible.
What changes do you think we should make in order to solve the problem?
I think we should make markAllMessagesAsRead() use the latest REPORT_ATTRIBUTES collection from Onyx when it evaluates isUnread(), instead of relying on a possibly unhydrated component snapshot. The old distinction must remain intact: an existing derived entry whose isEmpty value is false is authoritative; only a genuinely absent entry should use generateIsEmptyReport().
Illustratively:
- isUnread(report, threadReport, isArchived)
+ isUnread(report, threadReport, isArchived, reportAttributes?.reports[report.reportID]?.isEmpty)
For each selected report, the optimistic merge should also clear manuallyMarkedUnreadReportActionID, preserve its previous value in failureData, and notify an already-mounted report view that the explicit read watermark changed:
- {lastReadTime: newLastReadTime}
+ {lastReadTime: newLastReadTime, manuallyMarkedUnreadReportActionID: null}
After queuing the write, emit readNewestAction_<reportID> with the new timestamp for every selected report. This updates the local marker immediately while the Onyx merge clears the manual anchor.
The rollback must restore both lastReadTime and manuallyMarkedUnreadReportActionID. I would also add focused action tests for:
- a non-empty report whose actions are not loaded but whose derived
isEmptyvalue isfalse; - a manually marked unread report;
- empty and already-read reports remaining excluded;
- API failure restoring the previous timestamp and manual marker.
This keeps the current filtering of archived, empty, and already-read reports unchanged. It only supplies the authoritative emptiness state and resets marker state for reports the action already determined should be marked read.
What alternative solutions did you explore? (Optional)
I considered always recalculating emptiness from report actions, but that preserves the Android failure because mobile does not necessarily have every report’s actions in memory.
I also considered changing useUnreadMarker() to follow every lastReadTime update. That would broaden the behavior of automatic reads, which intentionally do not always dismiss the marker. Sending the existing explicit-read event from the bulk action is narrower.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Long-pressing an Inbox tab and choosing "Mark all as read" (confirmed in the confirmation modal) does nothing on Android: unread chats stay bold in the LHN, the Unread tab badge keeps its count, and the new-message markers inside the chats remain. The unread state also survives an app restart, which shows the server was never told anything. This is a 9.4.90-0 staging regression from PR #100693.
What is the root cause of that problem?
Until PR #100693, markAllMessagesAsRead decided "is this report unread?" through isUnread() → isEmptyReport(), and isEmptyReport() read the cached isEmpty flags from ONYXKEYS.DERIVED.REPORT_ATTRIBUTES live, at execution time, via a module-level Onyx subscription inside ReportUtils.
PR #100693 removed that module-level read and made every caller pass the derived value in as a parameter. For this flow the value now comes from the useReportAttributes() hook inside InboxTabSelector and is captured in the confirmMarkAllAsRead closure, where it has to survive the popover hide → confirmation modal → promise resolution chain before markAllMessagesAsRead finally executes:
https://github.com/Expensify/App/blob/fb30637cb4e97a70707cfb0d65a73f32b850b696/src/pages/inbox/sidebar/InboxTabSelector.tsx#L88-L103
At execution time the action iterates every report and skips each one that isUnread(...) reports as read, using the snapshot's isEmpty for that report:
https://github.com/Expensify/App/blob/fb30637cb4e97a70707cfb0d65a73f32b850b696/src/libs/actions/Report/MarkAllMessageAsRead.tsx#L57-L79
isUnread() returns false for any report whose derivedIsEmptyReport argument is true, because isEmptyReport() now trusts the passed-in flag over recomputing:
https://github.com/Expensify/App/blob/fb30637cb4e97a70707cfb0d65a73f32b850b696/src/libs/ReportUtils.ts#L9793-L9800
https://github.com/Expensify/App/blob/fb30637cb4e97a70707cfb0d65a73f32b850b696/src/libs/ReportUtils.ts#L9689-L9694
So the correctness of the whole action now depends on a render-time snapshot of the derived report attributes still matching live Onyx state when the user finishes the confirm flow. On native that assumption breaks: the derived REPORT_ATTRIBUTES value keeps recomputing while a fresh session hydrates (report actions and report fields arrive after the closure was created), and the memoized long-press → popover → confirm-modal callback chain holds on to the older snapshot until the promise resolves. With a lagging snapshot, isEmpty is stale-true for the unread reports, isUnread() returns false for every one of them, the loop continues each time, reportIDList stays empty, and the function returns before writing optimisticData or calling the MarkAllMessagesAsRead API. That produces exactly the reported symptom: the modal confirms, nothing changes locally, and nothing changes on the server either.
Notably, the same PR recognized this problem for the other imperative consumer it touched: it gave UnreadIndicatorUpdater its own module-level Onyx.connectWithoutView subscription to the derived value so the unread-badge computation always reads current data. markAllMessagesAsRead — an equally imperative, non-UI action that already owns two module-level subscriptions for reports and report actions — was instead left depending on a UI-render snapshot:
https://github.com/Expensify/App/blob/fb30637cb4e97a70707cfb0d65a73f32b850b696/src/libs/UnreadIndicatorUpdater/index.ts#L68-L75
What changes do you think we should make in order to solve the problem?
Make markAllMessagesAsRead read the derived attributes at execution time instead of accepting a render-time snapshot. In src/libs/actions/Report/MarkAllMessageAsRead.tsx, add a module-level Onyx.connectWithoutView subscription to ONYXKEYS.DERIVED.REPORT_ATTRIBUTES alongside the file's existing allReports and allReportActions subscriptions — the exact pattern PR #100693 itself established in UnreadIndicatorUpdater/index.ts for the same kind of non-UI consumer — and use that subscription's isEmpty flag for each report inside the loop. Then remove the reportAttributesDerived parameter from the function signature and from its two callers: InboxTabSelector (which can also drop its useReportAttributes() subscription, added only to feed this parameter) and MarkAllMessagesAsReadHandler (which can drop the ref plus the effect that syncs it). This keeps the epic's goal — no module-level derived read inside ReportUtils — while restoring the invariant that the unread check always sees current data, on every platform and no matter how long the user leaves the confirmation modal open.
Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/101684-mark-all-read-live-derived?expand=1
What alternative solutions did you explore? (Optional)
Keeping the parameter but feeding it through a ref that an effect keeps updated (the pattern the keyboard-shortcut handler uses) shrinks the staleness window, but it still makes an imperative action's correctness depend on each caller wiring UI state plumbing correctly, and every future caller would have to repeat it. Passing undefined from the callers so isEmptyReport() falls back to recomputing emptiness per report also fixes the bug, but it silently abandons the cached derived value for this path, which is the exact cost the derived-attributes cache exists to avoid.
I added the Help Wanted label, so this issue is now open to external contributors. It already had the External label.
Job added to Upwork: https://www.upwork.com/jobs/~022106030737448785107
Proposal
What is the root cause of that problem?
markAllMessagesAsRead() and the Inbox views that show unread state disagree on two things: which chats count as unread, and how far the read watermark has to advance to clear them.
The Unread tab list, its count badge, and the per-row unread marker are driven by a report-level unread test that never passes the report's one-transaction thread:
https://github.com/Expensify/App/blob/4f5dff4dde75e862904115a203ccff0a4aa4db93/src/libs/SidebarUtils.ts#L987-L995
The tab filter and the badge count read only the cached flag that test produces:
https://github.com/Expensify/App/blob/4f5dff4dde75e862904115a203ccff0a4aa4db93/src/libs/SidebarUtils.ts#L1022
https://github.com/Expensify/App/blob/4f5dff4dde75e862904115a203ccff0a4aa4db93/src/libs/SidebarUtils.ts#L1050
The same thread-less definition paints the unread row marker:
https://github.com/Expensify/App/blob/4f5dff4dde75e862904115a203ccff0a4aa4db93/src/libs/SidebarUtils.ts#L839
The bulk action instead re-tests every report itself, and it passes the one-transaction-thread report into that test:
https://github.com/Expensify/App/blob/4f5dff4dde75e862904115a203ccff0a4aa4db93/src/libs/actions/Report/MarkAllMessageAsRead.tsx#L67
That extra argument changes the result inside isUnread() in two ways. It replaces the effective last-visible-action timestamp with the maximum of the report's and the thread's, and it makes the self-authored short-circuit evaluate the thread's driving actor, so a chat whose newest visible thread action is the current user's own is judged read by the producer while the Inbox still lists and counts it as unread:
https://github.com/Expensify/App/blob/4f5dff4dde75e862904115a203ccff0a4aa4db93/src/libs/ReportUtils.ts#L13182-L13186
https://github.com/Expensify/App/blob/4f5dff4dde75e862904115a203ccff0a4aa4db93/src/libs/ReportUtils.ts#L9815-L9818
The thread leg only reaches reports that can own a transaction thread, because the lookup returns early unless the report itself is an IOU, expense, or invoice report:
https://github.com/Expensify/App/blob/4f5dff4dde75e862904115a203ccff0a4aa4db93/src/libs/ReportActionsUtils.ts#L1990-L2000
The two definitions have also drifted the other way: the Inbox predicate additionally requires a non-empty lastActorAccountID and a non-muted notification preference, which the bulk action never checks. Either direction of drift is enough for the action to skip a chat the Inbox is displaying as unread.
Second, the watermark the action writes is a single client-clock value computed once for the whole batch:
https://github.com/Expensify/App/blob/4f5dff4dde75e862904115a203ccff0a4aa4db93/src/libs/actions/Report/MarkAllMessageAsRead.tsx#L47
https://github.com/Expensify/App/blob/4f5dff4dde75e862904115a203ccff0a4aa4db93/src/libs/actions/Report/MarkAllMessageAsRead.tsx#L72
and the same value is sent to the server for persistence:
https://github.com/Expensify/App/blob/4f5dff4dde75e862904115a203ccff0a4aa4db93/src/libs/actions/Report/MarkAllMessageAsRead.tsx#L97-L102
getDBTimeWithSkew() only pushes the client clock forward when a positive skew is already known, so this is the plain client "now" whenever skew is not applied:
https://github.com/Expensify/App/blob/4f5dff4dde75e862904115a203ccff0a4aa4db93/src/libs/NetworkState.ts#L257-L263
Read state, however, is not "newer than the previous value" — isUnread() requires the stored lastReadTime to be at or after the report's last visible action, the one-transaction thread's last visible action, and the report's lastMentionedTime:
https://github.com/Expensify/App/blob/4f5dff4dde75e862904115a203ccff0a4aa4db93/src/libs/ReportUtils.ts#L9793-L9825
A batch watermark older than any of those leaves the reports it just marked read still unread for every reader of that state, and the server persists the same value. The thread-aware test also feeds the app-level unread indicator, so it stays lit for a chat the action skipped:
https://github.com/Expensify/App/blob/4f5dff4dde75e862904115a203ccff0a4aa4db93/src/libs/UnreadIndicatorUpdater/index.ts#L100-L110
Regression context: the issue was filed from a regression-test run of PR #100693, and that PR did remove the module-level reportAttributesDerivedValue cache from ReportUtils.isEmptyReport(). Re-deriving the merge diff shows that part is behavior-neutral: every call site now threads the same derived isEmpty, and the derived value computes it with the same generateIsEmptyReport() fallback, so it cannot produce the reported symptom. The predicate and watermark mismatches above are present in the current code independently of that PR — the bulk action and the Inbox tab predicate have simply never been the same definition.
What changes do you think we should make in order to solve the problem?
-
Use one unread definition for both the Inbox and the bulk action. Extract the body of
getIsUnreadReportForInboxTab()(src/libs/SidebarUtils.ts:987-995) as the shared "the Inbox presents this chat as unread" predicate, including itslastActorAccountIDand notification-preference requirements, and havemarkAllMessagesAsRead()select its targets through it instead of its ownisUnread(report, oneTransactionThreadReport, ...)call (src/libs/actions/Report/MarkAllMessageAsRead.tsx:67). The Inbox list is the display authority, so the action must clear exactly what is displayed. If the thread should be part of that definition, it has to be adopted in the tab predicate as well — the two sides must read the same argument list so they cannot drift apart again. -
Floor the batch watermark instead of writing a raw client clock. The request carries one
lastReadTimefor the whole batch (src/libs/API/parameters/MarkAllMessagesAsReadParams.ts), so compute that value with the existing server-anchored helper, which applies skew in both directions and clamps forward past a floor:
https://github.com/Expensify/App/blob/4f5dff4dde75e862904115a203ccff0a4aa4db93/src/libs/NetworkState.ts#L274-L291
Use the newest timestamp among the selected reports as that floor — the maximum of each report's and its one-transaction thread's lastVisibleActionCreated (via getReportLastVisibleActionCreated(), src/libs/ReportUtils.ts:13182-13186) and each report's lastMentionedTime. The resulting value is written optimistically to every selected report and sent as the request lastReadTime, so both the client state and the persisted value satisfy isUnread() for every chat in the batch.
- Keep the rollback intact.
failureReportsstill restores each report's previouslastReadTime(src/libs/actions/Report/MarkAllMessageAsRead.tsx:73), so a failed request cannot strand a partial watermark.
Coverage note: this is all the fix the consumers need. The Inbox tab filter and badge already recompute from report state, and the app-level unread indicator (src/libs/UnreadIndicatorUpdater/index.ts:105) recomputes from the same reports, so once the written value clears isUnread() the tab list, the tab badge, the row marker, and the indicator clear together on their next recompute. No change to the tab filter itself is required, and the To-do tab path that passes an explicit reportIDs subset keeps working because the shared predicate and the floored watermark apply the same way there.
Test coverage:
- Extend the
markAllMessagesAsReadsuite intests/actions/ReportTest.ts(around line 3570) with a report whoselastVisibleActionCreatedis ahead of the client clock, asserting the writtenlastReadTimestill clears it (isUnread()false) rather than leaving it unread. - Add the same case for
lastMentionedTimebeing ahead of the client clock, asserting the mention marker is cleared. - Add an IOU/expense report with a one-transaction thread whose newest visible action is the current user's own and newer than the report's own last visible action, asserting the action marks it read and that the Inbox predicate agrees for that same report.
- Add a
tests/unit/SidebarUtilsTest.tscase pinning the shared predicate as the single source of truth, so the tab predicate and the bulk action's target set cannot diverge again. - Add a
tests/unit/useSidebarOrderedReportsTest.tsxcase asserting the Unread tab list andinboxTabCounts[CONST.INBOX_TAB.UNREAD]both drop the marked reports after the bulk action.
What alternative solutions did you explore? (Optional)
Rival A: make the Inbox predicate thread-aware (src/libs/SidebarUtils.ts:987-995) so the tab stops listing chats the bulk action will not clear. This loses because the report asks for unread chats to be cleared, not hidden: narrowing the tab list and the badge count would make genuinely unread chats disappear instead of read, and it would leave the row-level marker and the app-level indicator (which already use the thread-aware test) contradicting the tab. The producer has to write a state the consumers can read, not the consumers learn to ignore it.
Rival B: drop the client-supplied lastReadTime (src/libs/API/parameters/MarkAllMessagesAsReadParams.ts) and let the server stamp the watermark, which is what the endpoint did before that field was added. This loses because the optimistic write and the request must carry the same value for the client to show the cleared state immediately, and it fixes neither divergence: the target set would still be computed with the action's own unread test, so a chat the Inbox displays as unread would still be skipped before any request is made.
Rival C: fix only one leg — floor the watermark but keep the action's own target test, or unify the predicate but keep the raw client clock. Each loses on its own because the symptom needs both: reports the action skips are never written at all, and reports it does write are not reliably cleared while the watermark is a plain client clock value.
🤖 ProposalPolice™ is tracking duplicate proposals for this issue using an OpenAI Conversation. This comment stores that Conversation's ID and can be safely ignored.
Proposal
What is the root cause of that problem?
1. The Unread tab and "Mark all as read" use different definitions of "unread". The tab flag is computed without the one-transaction thread: https://github.com/Expensify/App/blob/e029fad955164435583153ee7f862942711273cb/src/libs/SidebarUtils.ts#L987-L995
markAllMessagesAsRead (and the LHN bold state) pass the thread:
https://github.com/Expensify/App/blob/e029fad955164435583153ee7f862942711273cb/src/libs/actions/Report/MarkAllMessageAsRead.tsx#L67
https://github.com/Expensify/App/blob/e029fad955164435583153ee7f862942711273cb/src/libs/SidebarUtils.ts#L839
With the thread, isUnread takes the later of the two lastReadTimes:
https://github.com/Expensify/App/blob/e029fad955164435583153ee7f862942711273cb/src/libs/ReportUtils.ts#L9849
So a one-expense report whose expense (thread) was already read, but whose report wasn't, shows in the Unread tab (not bold). "Mark all as read" treats it as read and skips it. When those are the only items left, reportIDList is empty and the action returns without an API call or any optimistic update:
https://github.com/Expensify/App/blob/e029fad955164435583153ee7f862942711273cb/src/libs/actions/Report/MarkAllMessageAsRead.tsx#L77-L79
Reproduced on web (dev). I logged the values inside the action for a report that the Unread tab was showing:
6133559146143422 {"derived":{"isEmpty":false,"oneTransactionThreadReportID":"2055341732240261"},"unread":false, ...}
reportIDList []
The report stays in the Unread tab and its lastReadTime doesn't change. A normal unread chat in the same run is marked read correctly. That also shows the derived isEmpty snapshot is present and correct here, so the "missing snapshot" theory isn't what breaks it on web.
2. The "New" marker isn't cleared. markAllMessagesAsRead only merges lastReadTime. It doesn't clear manuallyMarkedUnreadReportActionID, which pins the marker:
https://github.com/Expensify/App/blob/e029fad955164435583153ee7f862942711273cb/src/pages/inbox/report/shouldDisplayNewMarkerOnReportAction.ts#L65-L66
It also doesn't emit readNewestAction_<reportID>, which a mounted chat needs to move its marker:
https://github.com/Expensify/App/blob/e029fad955164435583153ee7f862942711273cb/src/hooks/useUnreadMarker.ts#L82-L94
What changes do you think we should make in order to solve the problem?
- Make the tab use the same check as the action. In
getReportsToDisplayInLHNandupdateReportsToDisplayInLHN, look up the thread withreportAttributes[reportID]?.oneTransactionThreadReportIDfromreports(both already receive it) and pass it throughgetIsUnreadReportForInboxTab→isUnread. I tested this locally: with the same state, the Unread tab shows "No unread chats", matching the LHN and the action. - In
updateReportsToDisplayInLHN, when a one-transaction thread changes, also recompute its parent (thread.parentReportID), so reading the expense updates the parent's tab flag right away. - In
markAllMessagesAsRead, addmanuallyMarkedUnreadReportActionID: nullto each marked report's optimistic data (restore it in the failure data). AfterAPI.write, emitreadNewestAction_<reportID>with the newlastReadTimeso open chats drop the "New" line. - Tests:
- SidebarUtils: a one-expense report whose thread was read isn't
isUnreadReport; a change to only the thread recomputes the parent. - MarkAllMessageAsRead: every report flagged for the Unread tab gets marked; the marker is cleared and the event is emitted; the failure data restores the marker.
- SidebarUtils: a one-expense report whose thread was read isn't
What alternative solutions did you explore? (Optional)
Having the action also mark reports that are unread only without the thread. That would clear the tab, but the tab and the LHN bold state would still disagree, and reports that are effectively read would get marked read again.