Skip to content

Stop requiring lastActorAccountID to show a chat as unread - #102653

Merged
lakchote merged 4 commits into
Expensify:mainfrom
mukhrr:fix/102117
Oct 16, 2026
Merged

lakchote merged 4 commits into
Expensify:mainfrom
mukhrr:fix/102117

Conversation

@mukhrr

@mukhrr mukhrr commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

A chat whose only visible message is a report preview arrives with an empty lastActorAccountID, and the LHN, the Unread tab and the search list all required that field before treating a report as unread, so a conversation the user had never opened showed as read. This removes the requirement from all three checks and relies on the empty-report check already in isUnread, which covers the case the requirement was added for.

Fixed Issues

$ #102117
PROPOSAL: #102117 (comment)

Tests

Two accounts are needed: account A with an existing Expensify account, and account B whose email has never been used.

  1. As account A, submit an expense to account B's unused email address.
  2. Sign out of account A in the same tab, without switching tabs or opening a new window.
  3. Sign in as account B and enter the magic code sent to that address.
  4. Open the Inbox.
  5. Verify the conversation with account A is bold in the LHN.
  6. Open the Unread tab and verify that conversation is listed there, and that the tab's count includes it.
  7. Open the conversation with account A, then go back to the Inbox.
  8. Verify the conversation is no longer bold and no longer appears in the Unread tab.
  9. Open the search field, type account A's email, and verify the result for that conversation is no longer bold.
  • Verify that no errors appear in the JS console

Offline tests

Unread state is read from data already in Onyx and this change adds no request, so the flow behaves the same offline.

  1. Complete the Tests steps above so the conversation with account A is bold.
  2. Turn off your network connection.
  3. Open the Inbox and verify the conversation is still bold and still listed in the Unread tab.
  4. Open the conversation, go back to the Inbox, and verify it is no longer bold.
  5. Turn the network back on and verify the read state stays the same.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

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

Screenshots/Videos

Android: Native
androis.app.mp4
Android: mWeb Chrome
android.web.mp4
iOS: Native
ios.app.mp4
iOS: mWeb Safari
ios.web.mp4
MacOS: Chrome / Safari
web.mp4

@mukhrr
mukhrr requested review from a team as code owners September 30, 2026 12:49
@melvin-bot
melvin-bot Bot requested review from ZhenjaHorbach and dylanexpensify and removed request for a team and dylanexpensify September 30, 2026 12:49
@melvin-bot

melvin-bot Bot commented Sep 30, 2026

Copy link
Copy Markdown

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

@melvin-bot
melvin-bot Bot removed the request for review from a team September 30, 2026 12:49
@mukhrr
mukhrr marked this pull request as draft September 30, 2026 13:07
A chat whose only visible action is a report preview arrives with an empty
lastActorAccountID, because the actor sits on the IOU report the preview
points at. isUnread() returns true for it, but getOptionData,
getIsUnreadReportForInboxTab and the option list's isOptionUnread each ANDed
that with lastActorAccountID and turned it back to false. So a conversation
the user had never opened rendered read in the LHN, the Unread tab reported
nothing to read, and search autocomplete showed it in regular weight.

That guard was a proxy for "the only message was deleted", which isUnread
now covers itself: it gates on isEmptyReport, and generateIsEmptyReport
resolves the last visible message through getLastVisibleAction, so a chat
whose only message was deleted still comes back empty and not bold.
@mukhrr
mukhrr marked this pull request as ready for review October 1, 2026 04:34
@mukhrr

mukhrr commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@ZhenjaHorbach this is ready

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

Will check the PR today or tomorrow morning!

@mukhrr

mukhrr commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@ZhenjaHorbach kindly bump

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

Sorry
I will try to check today or on the weekend!

@ZhenjaHorbach

ZhenjaHorbach commented Oct 9, 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
Screen.Recording.2026-10-16.at.12.47.25.mov
Android: mWeb Chrome
Screen.Recording.2026-10-16.at.12.47.25.mov
iOS: HybridApp
Screen.Recording.2026-10-16.at.12.42.32.mov
iOS: mWeb Safari
Screen.Recording.2026-10-16.at.12.37.49.mov
MacOS: Chrome / Safari
Screen.Recording.2026-10-16.at.12.26.57.mov

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@codex
Review this PR

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@MelvinBot
Review this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 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 ⚠️ Failed 2026-10-14T08:49:59.369084Z 99b7625 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.

@MelvinBot

Copy link
Copy Markdown
Contributor

Code review

The fix is sound for the reported bug. The removed lastActorAccountID guard has been redundant for the deleted-message case since isUnread gained its empty-report check. I found one side effect worth addressing and one test that doesn't prove what it claims.

1. New expense/IOU reports now show as unread to their creator (side effect)

  • buildOptimisticExpenseReport and buildOptimisticIOUReport set neither lastReadTime nor lastActorAccountID (ReportUtils.ts:7560-7586). MoneyRequestBuilder.ts:626-636 writes the report as-is.
  • The report isn't empty, so isUnread returns true at the !report.lastReadTime shortcut (ReportUtils.ts:9950-9951). That runs before the "last actor is me" check, so it applies even to the person who created the report.
  • Before this PR, the guard hid it. Now the report can appear bold in search results (prepareReportOptionsForDisplay) until the server responds, and for as long as you stay offline. The LHN only shows it when it's pinned, focused, or needs attention, because these reports use HIDDEN.
  • Please check this flow: create an expense offline, then search for the report. If it's bold, set lastReadTime on the optimistic expense/IOU report (the parent chat already gets one at MoneyRequestBuilder.ts:616).

2. The deleted-message test passes on main too

The fixture in SidebarUtilsTest.ts:1591-1592 sets lastActorAccountID: 18921695 and a lastReadTime. The old guard wouldn't have hidden it either, so the test doesn't show the guard is safe to remove. Please add these cases:

  • Never read (lastReadTime: undefined) and only message deleted (lastActorAccountID: 0, as optimisticReportLastData sets). Only the empty check prevents a bold row here.
  • The same deleted case for getIsUnreadReportForInboxTab.
Supporting details
  • The guard came from Fix - LHN - When you delete a message from a room, the conversation in the members remains bolded (Feb 2024). At that time isUnread had no empty check. fix empty chat displayed in focus mode (Apr 2024) added isEmptyReport, which covers that repro.
  • On delete, optimisticReportLastData clears lastMessageText and zeroes lastActorAccountID under the same condition (Report/index.ts:5827-5839), so the derived isEmpty catches it on the client. I didn't verify what the backend sends to other members after a delete. If it doesn't clear lastMessageText, their chat could now turn bold. The Tests section doesn't cover this, so it's worth a quick manual check with two accounts.
  • Upside: no other isUnread caller (tab badge, focus mode, "Mark as read") used this guard. The PR makes the bold state agree with them.

view run

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Failed to set up container
ℹ️ 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".

The existing deleted-message cases both set a real lastActorAccountID, which is the
shape where the removed guard was a no-op anyway. That isolates the empty-report
check inside isUnread, but it leaves untested the shape the server actually writes
on delete, where lastActorAccountID is zeroed and the chat was never read.

Add that case for getOptionData and for the Unread tab path. The tab test also
asserts the report is present in the set, because isUnreadReport reads falsy for a
report that was never displayed and would pass without it.
@mukhrr

mukhrr commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Code review

The fix is sound for the reported bug. The removed lastActorAccountID guard has been redundant for the deleted-message case since isUnread gained its empty-report check. I found one side effect worth addressing and one test that doesn't prove what it claims.

1. New expense/IOU reports now show as unread to their creator (side effect)

  • buildOptimisticExpenseReport and buildOptimisticIOUReport set neither lastReadTime nor lastActorAccountID (ReportUtils.ts:7560-7586). MoneyRequestBuilder.ts:626-636 writes the report as-is.
  • The report isn't empty, so isUnread returns true at the !report.lastReadTime shortcut (ReportUtils.ts:9950-9951). That runs before the "last actor is me" check, so it applies even to the person who created the report.
  • Before this PR, the guard hid it. Now the report can appear bold in search results (prepareReportOptionsForDisplay) until the server responds, and for as long as you stay offline. The LHN only shows it when it's pinned, focused, or needs attention, because these reports use HIDDEN.
  • Please check this flow: create an expense offline, then search for the report. If it's bold, set lastReadTime on the optimistic expense/IOU report (the parent chat already gets one at MoneyRequestBuilder.ts:616).

2. The deleted-message test passes on main too

The fixture in SidebarUtilsTest.ts:1591-1592 sets lastActorAccountID: 18921695 and a lastReadTime. The old guard wouldn't have hidden it either, so the test doesn't show the guard is safe to remove. Please add these cases:

  • Never read (lastReadTime: undefined) and only message deleted (lastActorAccountID: 0, as optimisticReportLastData sets). Only the empty check prevents a bold row here.
  • The same deleted case for getIsUnreadReportForInboxTab.

Supporting details

  • The guard came from Fix - LHN - When you delete a message from a room, the conversation in the members remains bolded (Feb 2024). At that time isUnread had no empty check. fix empty chat displayed in focus mode (Apr 2024) added isEmptyReport, which covers that repro.
  • On delete, optimisticReportLastData clears lastMessageText and zeroes lastActorAccountID under the same condition (Report/index.ts:5827-5839), so the derived isEmpty catches it on the client. I didn't verify what the backend sends to other members after a delete. If it doesn't clear lastMessageText, their chat could now turn bold. The Tests section doesn't cover this, so it's worth a quick manual check with two accounts.
  • Upside: no other isUnread caller (tab badge, focus mode, "Mark as read") used this guard. The PR makes the bold state agree with them.

view run

fixed 1, 2 seems not valid

@ZhenjaHorbach

ZhenjaHorbach commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

fixed 1, 2 seems not valid

Yeah
Agree!
And thanks for checking!

@melvin-bot
melvin-bot Bot requested a review from lakchote October 16, 2026 10:49

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

LGTM

@lakchote
lakchote merged commit 941fc57 into Expensify:main Oct 16, 2026
35 of 37 checks passed
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 lakchote has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/lakchote in version: 9.5.14-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed. This bug fix makes a chat you haven't opened show as unread (bold in the Inbox and listed in the Unread tab), which is what users already expect, so no existing article becomes incorrect.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.5.14-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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