Skip to content

Decompose ReportActionsList: 12#94938

Merged
rlinoz merged 17 commits into
Expensify:mainfrom
callstack-internal:decompose/ral-12-3
Jul 9, 2026
Merged

Decompose ReportActionsList: 12#94938
rlinoz merged 17 commits into
Expensify:mainfrom
callstack-internal:decompose/ral-12-3

Conversation

@LukasMod

@LukasMod LukasMod commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Before this PR the report-actions list ref was owned by context. ActionListContext exposed a shared
flatListRef: RefObject, the scroll manager dereferenced flatListRef.current, and each list attached
that context ref via ref={}. Attaching a context-sourced ref to ref={} is a render-time ref read, so
React Compiler bailed out of optimizing the list

This PR flips ownership. Each list now owns its ref locally and only publishes it to context.

  • ActionListContext no longer exposes a shared ref. It exposes two callbacks instead:
    • registerListRef(ref), where a list publishes its locally-owned ref on mount and clears it with null on unmount.
    • getListRef(), where scroll handlers resolve the ref at call time, never during render.
  • Each list creates const listRef = useRef<FlatList>(null), attaches ref={listRef} (a local ref the
    compiler can reason about), and registers it in a layout effect so the ref is live at commit, before the
    list's onLayout fires and reads it via getListRef().

Context (ownership flip)

src/pages/inbox/ActionListContext.tsx is new. It owns the context, the ActionListContextProvider
(value built inline from refs and accessors), and the useActionListContext() consumer hook. The value is
only stable refs and accessors and triggers no re-renders, so it stays a single provider. That's documented
inline with an eslint-disable rulesdir/context-provider-split-values.

src/pages/inbox/ReactionListContext.ts is renamed from ReportScreenContext.ts. The old file mixed the
action-list context with the reaction-list context. It now holds only the reaction-list context and types.
The action-list half moved to ActionListContext.tsx.

src/hooks/useActionListContextValue.ts is deleted. The provider owns its value inline now, so the separate
value-builder hook is gone, and so is the confusing useActionListContext / useActionListContextValue
name pair.

Scroll manager (resolve ref at call time)

In src/hooks/useReportScrollManager/index.ts and index.native.ts, every scrollTo* now calls
const listRef = getListRef() and guards listRef?.current at call time. The ref field is dropped from
the manager's return.

In src/hooks/useReportScrollManager/types.ts, ref is removed and scrollToIndex is unified to a single
signature, scrollToIndex(index, {isEditing?, animated?}). That replaces the old scrollToIndex(index, bool)
plus a separate scrollToIndexInstance. Platform defaults for animated are preserved: web animates and
native jumps instantly, which matches FlashList's default and the prior native behavior.

Threshold state (drop the render-time ref read)

ReportActionsList derives hasScrolledOverThreshold — "is the user scrolled more than
ACTION_VISIBLE_THRESHOLD (250px) away from the bottom of the inverted list" — and seeds it from the
persisted scroll offset so a remount restores the correct value on the first render. That initial
read used scrollOffsetRef.current inside the useState initializer, which is a render-time ref read:
React Compiler bailed on it and react-hooks/refs flagged it ("Cannot access refs during render").

ActionListContext now exposes getScrollOffset(): number, a snapshot accessor built from
scrollOffsetRef, alongside the raw ref. ReportActionsList initializes the state from
useState(() => getScrollOffset() >= CONST.REPORT.ACTIONS.ACTION_VISIBLE_THRESHOLD) and no longer
destructures scrollOffsetRef at all. Reading through an opaque accessor keeps the render path free of a
traceable ref read, so the compiler no longer bails and the lint warning is gone.

Behavior is unchanged: the accessor returns the same value the ref held, still read once synchronously in
the lazy initializer. It is deliberately not moved to an effect — the value must be correct on the
first render because useMarkAsRead reads isScrolledToEnd (!hasScrolledOverThreshold) in a mount
effect, and a first-render false would let a scrolled-up report get marked read.

Type extraction (fix layering)

src/components/FlashList/types.ts is new. FlatListRefType lives next to FlashList now instead of being
imported out of a page-level context module, and InvertedFlashList imports it from here.

Fixed Issues

$ #89773
PROPOSAL:

Tests

  • Verify that no errors appear in the JS console

1. Scroll-to-bottom (floating "new messages" counter)

  1. Open a long chat and scroll up until the floating message counter appears.
  2. Tap the floating counter. List jumps to the newest message (bottom) and the counter disappears. Report is marked as read.

2. New incoming message auto-scroll (live tail)

  1. Open a chat scrolled to the bottom.
  2. Have another user (or yourself in a second session) send a new message. List scrolls to reveal the new message.
  3. Scroll up first, then receive a new message. List does not force-scroll; the floating counter appears instead.

3. Deep-link to an old message, then a new message

  1. With cache cleared, deep-link to an old message in a report. List opens anchored to the linked message and highlights it
  2. Now, from the same open report, compose and send a message yourself. Chat jumps to the bottom.

4. List-switch ref hand-off (timing)

  1. Navigate rapidly between two different reports several times.
  2. Immediately tap the floating counter / trigger a scroll right after a report opens.
  3. No crash, no "scrollToIndex out of range" error; scroll either works or harmlessly no-ops during the
    brief unmount→mount window.

Offline tests

QA Steps

  • Verify that no errors appear in the JS console
    Same as tests

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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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
android.mov
Android: mWeb Chrome
android.web.mov
iOS: Native
ios.mov
iOS: mWeb Safari
ios.web.mov
MacOS: Chrome / Safari
web.mov

@LukasMod

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 6a9cb88ad0

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

Comment thread src/pages/inbox/report/ReportActionsList.tsx Outdated
@LukasMod
LukasMod force-pushed the decompose/ral-12-3 branch from e9315ee to f40a3fa Compare June 30, 2026 13:46
@LukasMod

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: f40a3fa787

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

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
...c/components/FlashList/InvertedFlashList/index.tsx 100.00% <ø> (ø)
...equestReportView/MoneyRequestReportActionsList.tsx 63.89% <100.00%> (-0.24%) ⬇️
src/components/Reactions/EmojiReactionBubble.tsx 82.60% <ø> (ø)
...omponents/Reactions/ReportActionReactionBubble.tsx 6.66% <ø> (ø)
src/hooks/useReportActionsScroll.ts 98.23% <100.00%> (ø)
src/hooks/useReportScrollManager/index.native.ts 90.47% <100.00%> (+37.53%) ⬆️
src/pages/Search/SearchMoneyRequestReportPage.tsx 0.00% <ø> (ø)
src/pages/inbox/ActionListContext.tsx 100.00% <100.00%> (ø)
src/pages/inbox/ReactionListContext.ts 50.00% <ø> (ø)
src/pages/inbox/ReactionListWrapper.tsx 48.78% <ø> (ø)
... and 8 more
... and 17 files with indirect coverage changes

@LukasMod
LukasMod force-pushed the decompose/ral-12-3 branch from f40a3fa to bfd4898 Compare July 1, 2026 07:22
@LukasMod

LukasMod commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: bfd4898df0

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

@LukasMod
LukasMod force-pushed the decompose/ral-12-3 branch from bfd4898 to e7465c4 Compare July 1, 2026 12:22
@LukasMod
LukasMod marked this pull request as ready for review July 6, 2026 11:06
@LukasMod
LukasMod requested review from a team as code owners July 6, 2026 11:06
@melvin-bot
melvin-bot Bot requested review from DylanDylann and removed request for a team July 6, 2026 11:06
@melvin-bot

melvin-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

@DylanDylann 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 requested a review from JmillsExpensify July 6, 2026 11:06
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: e4464a6366

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

@LukasMod

LukasMod commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@DylanDylann I applied your suggestions, thanks!

@LukasMod
LukasMod requested a review from DylanDylann July 7, 2026 12:38

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

@melvin-bot
melvin-bot Bot requested a review from rlinoz July 7, 2026 15:23
@DylanDylann

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 667862055b

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

Copy link
Copy Markdown
Contributor

🤖 I couldn't run the manual tests on Android in this run — the Android testing environment isn't provisioned here.

Driving the app on Android requires a booted emulator with the standalone NewDot dev build installed, Metro running on :8081, and the agent-device CLI to drive the UI. In this run none of those are present (no emulator/device attached, Metro not running, agent-device not installed), so there's nothing for me to test against, and building + booting that whole stack from scratch is out of scope for this path. I'm not going to report pass/fail I didn't actually observe.

To get these run, this needs to go through the dedicated Android testing workflow (the one that boots the emulator and installs the dev build) rather than the standard MelvinBot path. Once that environment is up, the four flows to verify are:

  1. Scroll-to-bottom counter — scroll up in a long chat, tap the floating counter → list jumps to newest, counter clears, report marked read.
  2. Live-tail auto-scroll — at bottom, a new incoming message auto-scrolls; scrolled up, it shows the counter instead of force-scrolling.
  3. Deep-link + new message — deep-link (cache cleared) anchors and highlights the linked message; sending a message then jumps to bottom.
  4. List-switch ref hand-off — rapidly switch reports and trigger a scroll right after open → no crash, no "scrollToIndex out of range".

cc LukasMod

@DylanDylann

Copy link
Copy Markdown
Contributor

Oh my bad, I added Android video

@MelvinBot

This comment was marked as resolved.

@rlinoz

rlinoz commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Will take a look first thing tomorrow, sorry.

@LukasMod

LukasMod commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Conflicts resolved, updated to latest main

@LukasMod

LukasMod commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Working on failing test

@LukasMod

LukasMod commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@rlinoz ready again

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

Thank you!

@rlinoz
rlinoz merged commit 8b48c09 into Expensify:main Jul 9, 2026
34 checks passed
@OSBotify

OSBotify commented Jul 9, 2026

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

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🚧 rlinoz 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/rlinoz in version: 9.4.33-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes required.

I reviewed the changes in this PR against Expensify's help site content under App/docs/articles.

This is an internal engineering refactor with no user-facing behavior change:

  • It flips ownership of the report-actions list ref (context-owned → list-owned) so React Compiler can optimize the list.
  • It restructures/renames context modules (ActionListContext.tsx, ReactionListContext.ts), moves type definitions, and unifies the scroll manager's scrollToIndex signature.
  • The PR explicitly states "Behavior is unchanged" — scroll-to-bottom, live-tail auto-scroll, deep-linking, and mark-as-read all continue to work exactly as before.

No features, tab names, settings labels, buttons, pricing, or workflows described on the help site are added, removed, or altered by these changes, so there is nothing to document. No draft docs PR was created.

@LukasMod, flagging for your awareness — no linked help site PR was needed here. If you believe a user-facing behavior did change and warrants a docs update, let me know the specific behavior and I'll draft one.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/lakchote in version: 9.4.33-8 🚀

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.

6 participants