Repository navigation
fix: Opening a room at its oldest unread message never loads newer messages - #107793
Conversation
|
Sorry for the delay here, I need a bit more time to test this thoroughly |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
@zeryns can you pls make sure to finish this one before posting new proposals?! Thanks! |
|
Hi @mukhrr, I have a few updates on this PR While testing on mobile, I found newer messages could still get stuck in two cases
Screen.Recording.2026-11-25.at.00.49.33.mov
Screen.Recording.2026-11-25.at.01.42.26.movTo fix this, I added a There is also one more thing I left out of this PR and wanted to check with you first. About the early read, in this PR I only added the missing We can fix it by holding the mount read until I'm not sure this delay on read is what the product/design team would want, so I left it out of this PR for now. Let me know what you think we should do next! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bbeb022021
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@MelvinBot review |
Review: one confirmed issueP2 — Retry the skipped read when newer-message loading finishes The new guard correctly postpones marking the chat as read, but nothing retries it when Recheck the pending read when pagination finishes, while preserving viewport/focus eligibility. The new test manually invokes completion again, masking the missing production trigger. This confirms the existing reviewer’s P2 finding. Validation: Two focused unit suites passed: 82 tests. Browser behavior was not verified. |
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
|
@zeryns I think test 2 fails when the unread messages fit in one more page.
Clear cache, have 60 unread, open the DM. ONe thing though, it is the same on main as well. So @marcaaron we are still good to include this in this PR, aren't we? since it's not what #105204 directly asks to fix, but related in the end |
hmm yeah it makes sense to hold the mount read until |
|
@zeryns Also, right after |
| useEffect(() => { | ||
| if (!hasNewerActions || !newestFetchedReportActionID || requestedNewerCursorRef.current === newestFetchedReportActionID || listHeightRef.current <= 0) { | ||
| return; | ||
| } | ||
| const scrollOffset = listRef.current?.getAbsoluteLastScrollOffset?.(); | ||
| if (scrollOffset === undefined || scrollOffset > listHeightRef.current * START_REACHED_THRESHOLD) { | ||
| return; | ||
| } | ||
| loadNewerChatsAfterTransitions(); | ||
| }, [hasNewerActions, newestFetchedReportActionID, listRef, loadNewerChatsAfterTransitions]); | ||
|
|
There was a problem hiding this comment.
can you pls use the same guards as useMoneyRequestReportPagination (hasFinishedInitialLoad, isLoadingNewerReportActions) and wrap the call in useEffectEvent so deps are only the cursor and hasNewerActions? I think this also fixes the extra request on open
There was a problem hiding this comment.
Updated! The extra request on open was actually coming from onStartReached and not the effect. FlashList calls it twice on open, both before the first GetNewerActions comes back. The guards are in the shared load function now, so onStartReached goes through them too and makes it just one request
One small diff tho. I've add the guard in the deps as well. Without it, a second visit would get stuck, because the cursor moves while the response is still marked as loading
hmm I'm not sure if it counts as failing and it is expected IMO. In my test, for the jump, could you share where you tested it? I tried the same steps but couldn't reproduce it. Your numbers do match what happens when MVCP is already off when the last page lands tho, so the list ends up around 34-54 |
@mukhrr I tried this locally, and it adds a delay before the chat is marked as read. It only kicks in when new messages arrived since the last visit, so the cached newest page is out of date On the current PR (and main as well), opening the chat sends Without the hold (this PR & main)Screen.Recording.2026-11-26.at.18.29.37.movWith the hold, With the hold, normal connectionScreen.Recording.2026-11-26.at.18.24.49.movOn a slow connection (3G simulation) the chat stays unread for about 2 seconds after opening, then it's read once With the hold, 3G connectionScreen.Recording.2026-11-26.at.18.26.07.movAnd also, if the user leaves the chat before With the hold, leaving before OpenReport returns (3G)Screen.Recording.2026-11-26.at.18.39.26.movSo the hold makes sure the chat isn't marked as read before the new messages load, but the cost is a short delay before the read, and if the user leaves within that window the chat stays unread. It's also a behavior change from main. Do you think we should add this? |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 43bcd58ce8
ℹ️ 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".
| if (!hasNewerActions || !newestFetchedReportActionID || requestedNewerCursorRef.current === newestFetchedReportActionID || listHeightRef.current <= 0) { | ||
| return; |
There was a problem hiding this comment.
Replay start requests skipped during the initial report load
When a partially cached chat already has a cursor and the user reaches its loaded bottom while OpenReport is pending, onStartReached now returns at the loading guard. If OpenReport returns the same page/cursor, clearing the loading flag cannot resume pagination: this comparison matches the cursor used to initialize requestedNewerCursorRef, despite no newer request having been made. Since FlashList has consumed its start-zone callback, newer messages remain unloaded until the user scrolls away and back. Track the deferred start request or initialize the ref as unrequested so finishing the initial load retries it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not sure about this one. I've tested this on native app, desktop and mobile web, but couldn't reproduce it, even when forcing the conditions (failing the first GetNewerActions and delaying OpenReport)
On the first visit in a session, the list remounts after OpenReport finishes, so onStartReached runs again. On later visits, onStartReached fires before OpenReport sets the loading flag, so it isn't skipped and the request just waits for OpenReport to finish
| @@ -274,6 +274,7 @@ function useMarkAsRead({ | |||
| const shouldReadOnReportChange = ((isVisible && Visibility.hasFocus()) || isFromNotification) && !hasNewerActions && isScrolledToEnd; | |||
There was a problem hiding this comment.
@zeryns comparing lastVisibleActionCreated with newest loaded action doesnt work, newest message is already in Onyx on mount so read still goes out early. Lets add the hold, but only while OpenReport is loading so normal opens read right away. cc @marcaaron
There was a problem hiding this comment.
updated! however, this approach still has the cost I mentioned here
one small note: we couldn't use isLoadingInitialReportActions for the check, because OpenReport hasn't set it yet when the chat opens, so the chat was still read right away instead of waiting for OpenReport
There was a problem hiding this comment.
what happens if OpenReport fails? Hold only clears when pages change, so chat may stay unread untill next open. Can you check pls
There was a problem hiding this comment.
oh yeah, when OpenReport fails the pages don't change, so the hold stayed on and the chat stayed unread
updated it so the hold also ends once OpenReport finishes, so the chat is read right after a failure too. Could you please review it again? thanks!
hmmm, I am not able to rerpoduce this anymore too |
… page is out of date
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
Reviewer Checklist
Screenshots/VideosAndroid: HybridApp107793-android-app.mp4Android: mWeb Chrome107793-android-web.mp4iOS: HybridApp107793-ios-app.mp4iOS: mWeb Safari107793-ios-web.mp4MacOS: Chrome / Safariweb.mp4 |
|
🚧 marcaaron has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/marcaaron in version: 9.5.57-0 🚀
|
|
No help site update needed — this PR restores expected message loading and read-status behavior when opening older messages, without adding a feature or making existing help instructions incorrect. |
Explanation of Change
Opening a chat at an older message (its oldest unread message, a message marked as unread, or a linked message) stopped loading newer messages partway, and could mark the chat as read before they loaded. This PR:
maintainVisibleContentPositionon while there are newer messages, so each page loads below the message being read instead of leaving the user stuck at the bottomonStartReachedonce there are newer messages to load, so FlashList one call isn't used up earlyFixed Issues
$ #105204
PROPOSAL: #105204 (comment)
Tests
Test 1: Newer messages keep loading
Test 2: The chat isn't marked as read while newer messages are still loading
ReadNewestActionrequest in the network tab).Test 3: Opening a link to an older message
Offline tests
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android-Native-App.mov
Android-Native-App-2.mov
Android-Native-App-3.mov
Android: mWeb Chrome
Android-Mobile-Web.mov
Android-Mobile-Web-2.mov
Android-Mobile-Web-3.mov
iOS: Native
iOS-Native-App.mov
iOS-Native-App-2.mov
iOS-Native-App-3.mp4
iOS: mWeb Safari
iOS-Mobile-Web.mov
iOS-Mobile-Web-2.mov
iOS-Mobile-Web-3.mov
MacOS: Chrome / Safari
Desktop-Web.mp4
Desktop-Web-2.mp4
Desktop-Web-3.mov