Skip to content

Show Latest messages pill in read chats by using ACTION_VISIBLE_THRES… - #100793

Merged
tylerkaraszewski merged 4 commits into
Expensify:mainfrom
yusufdeveloper2903:fix/98708-latest-messages-pill-read-chat
Sep 18, 2026
Merged

tylerkaraszewski merged 4 commits into
Expensify:mainfrom
yusufdeveloper2903:fix/98708-latest-messages-pill-read-chat

Conversation

@yusufdeveloper2903

Copy link
Copy Markdown
Contributor

Explanation of Change

In a chat with no unread messages, the "Latest messages" pill only appeared after scrolling more than LATEST_MESSAGES_PILL_SCROLL_OFFSET_THRESHOLD (2000px). Chats with a shorter scroll range never reach that, so the pill never showed. The rest of the app already treats 250px (ACTION_VISIBLE_THRESHOLD) as "away from the newest message".

This PR removes the 2000px constant and uses ACTION_VISIBLE_THRESHOLD for both the show and hide checks in updatePillVisibility. Both checks have to change, otherwise the pill flickers between visible and hidden on every scroll event. All other guards are unchanged (unread marker, aligned-to-top, newer actions, initial positioning). Unit tests now cover a short read chat, consecutive scroll events, the lower bound, and unread chats.

Fixed Issues

$ #98708
PROPOSAL: #98708 (comment)

Tests

  1. Open a chat with no unread messages and a short history (slightly more than one screen, e.g. ~15 messages).
  2. Scroll up to the oldest message.
  3. Verify the grey "Latest messages" pill appears.
  4. Scroll up and down a little while staying away from the bottom, and verify the pill stays visible without flickering.
  5. Tap the pill and verify the chat scrolls to the newest message and the pill disappears.
  6. Scroll up again, then scroll back down to the bottom manually, and verify the pill hides near the bottom.
  7. Open a chat with unread messages, scroll up, and verify the green "New messages" pill still behaves as before.
  8. Open an expense report, scroll through it, and verify the "Latest messages" pill does not appear.
  • Verify that no errors appear in the JS console

Offline tests

Same as tests, while offline. The change only affects scroll-based UI and has no network dependency.

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

BEFORE FIX:

REC-20260910123238.mp4

AFTER FIX:

REC-20260910123402.mp4
Android: mWeb Chrome AFTER FIX:
REC-20260910124023.mp4
iOS: Native AFTER FIX:
REC-20260910124935.mp4
iOS: mWeb Safari AFTER FIX:
REC-20260910125059.mp4
MacOS: Chrome / Safari AFTER FIX:
REC-20260910125158.mp4

@yusufdeveloper2903
yusufdeveloper2903 requested review from a team as code owners September 10, 2026 08:11
@melvin-bot
melvin-bot Bot requested review from ZhenjaHorbach and heyjennahay and removed request for a team and heyjennahay September 10, 2026 08:11
@melvin-bot

melvin-bot Bot commented Sep 10, 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 10, 2026 08:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1821c07825

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

@ZhenjaHorbach

ZhenjaHorbach commented Sep 14, 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 proper code patterns were followed (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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • 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 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 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.
  • 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
2026-09-17.11.57.20.mov
Android: mWeb Chrome
2026-09-17.11.57.20.mov
iOS: HybridApp
2026-09-17.11.52.58.mov
iOS: mWeb Safari
2026-09-17.11.45.21.mov
MacOS: Chrome / Safari
2026-09-17.11.42.55.mov

@yusufdeveloper2903

Copy link
Copy Markdown
Contributor Author

Resolved the merge conflicts and merged latest main into this branch

@tylerkaraszewski

Copy link
Copy Markdown
Contributor

@ZhenjaHorbach - the reviewer checklist is not complete. Are you still working on it?

@ZhenjaHorbach

ZhenjaHorbach commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

@ZhenjaHorbach - the reviewer checklist is not complete. Are you still working on it?

Yes
I will complete the checklist and approve it tomorrow morning

@tylerkaraszewski

Copy link
Copy Markdown
Contributor

Conflicts

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

Minor conflicts
So LGTM again

@tylerkaraszewski
tylerkaraszewski merged commit f253024 into Expensify:main Sep 18, 2026
36 of 38 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

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

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/tylerkaraszewski in version: 9.4.90-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes are required for this PR. I did not create a docs PR.

Why: this PR only changes a scroll threshold constant so the existing Latest messages pill appears in short, already-read chats. It adds no feature, no setting, and no user-facing copy. The help site never documented the pill or the 2000px behavior, so there is nothing to correct.

What I checked

The change — src/pages/inbox/report/useReportUnreadMessageScrollTracking.ts:92 and :102 now both use ACTION_VISIBLE_THRESHOLD (250px) instead of the removed LATEST_MESSAGES_PILL_SCROLL_OFFSET_THRESHOLD (2000px). MoneyRequestReportActionsList.tsx passes shouldBeAlignedToTop so expense reports keep their current behavior. The rest is unit tests.

The docs — I searched all of docs/articles for the pill and its surrounding concepts:

  • latest messages, new messages pill, floating, counter, pill → no matches anywhere in docs/articles.
  • unread → only the Inbox Unread tab in Navigating-New-Expensify.md and the #focus priority mode in Prioritize-and-Pin-Chats.md. Neither describes in-chat scrolling.
  • No chat article covers scrolling within a conversation, so there is no page where an accurate sentence would even fit without inventing a new section.

Per HELP_AUTHORING_GUIDELINES.md, help articles cover what a user needs to do a task. A pill that appears automatically when you scroll up needs no instruction, and documenting a restored default would add noise rather than help.

If you would rather have the pill documented anyway — for example a short "Return to the newest message" step in a chat article — reply and I will draft it.

@yusufdeveloper2903, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/lakchote in version: 9.4.90-2 🚀

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

Bundle Size Analysis (Sentry):

@@ -89,7 +89,7 @@ export default function useReportUnreadMessageScrollTracking({

// display floating button if we're scrolled more than the offset
if (

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.

Lowering this from 2000 to ACTION_VISIBLE_THRESHOLD (250) made the pill depend on a stale scrollOffsetRef. When a chat is opened from a link to an old message and the user sends a message, the list remounts at the live tail at offset 0 and emits no scroll event. The next onContentSizeChange calls trackVerticalScrolling(undefined), sees the old offset is above 250 and shows "Latest messages" again, even though the list is already at the bottom. With the 2000 threshold most stale offsets stayed below the limit, so this was rarely visible.

The tests added here only covered real scroll events, so they could not catch it.

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.

6 participants