Skip to content

PoC: Simplify the report actions list pipeline and remove repeated work - #106703

Closed
chrispader wants to merge 5 commits into
Expensify:mainfrom
margelo:@chrispader/perf/report-actions-pipeline-poc
Closed

chrispader wants to merge 5 commits into
Expensify:mainfrom
margelo:@chrispader/perf/report-actions-pipeline-poc

Conversation

@chrispader

@chrispader chrispader commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

The report actions list builds its rows through a chain of similarly named arrays, and several names mean different things in different files. The chain also repeats work on every message. Each reader of a report sorts it again, two derived values hand every subscriber a new value even when a write changes nothing, and the list re-renders rows whose content didn't change. This proof of concept shows how much simpler and faster the chain gets, so we can agree on the approach before splitting it into smaller PRs.

Each stage now has one name, documented in useReportActionsListModel:

Stage New name Replaces
Every stored action of the report, hidden ones included cachedActions sortedAllReportActions
The continuous part around the linked, unread, or newest action windowActions reportActions, unfilteredReportActions
Without deleted expenses and hidden report previews reportViewActions allReportActions, filteredReportActions
Merged with the one-expense thread, plus placeholder rows combinedActions reportActions
What the list works with, hidden actions included listActions sortedReportActions, paymentFilteredReportActions
The actions that render as rows visibleActions sortedVisibleReportActions, visibleReportActions, paymentFilteredVisibleReportActions
Rows plus the streamed Concierge reply visibleActionsWithDraft renderedVisibleReportActions

All visibility rules now run in useReportActionsVisibility, including the pay action and support survey rules that lived in the list content. The PoC also removes repeated work:

  • Every reader of a report shares one sort per Onyx value.
  • The deprecated sort cache in ReportAlternateTextUtils sorted the actions of every report in the account on each write. It now sorts only the reports a write changed.
  • visibleReportActions and sortedReportActions keep their previous value when nothing changed, so Onyx skips the write and its notifications. They also skip report writes that don't change their inputs, like a new lastReadTime, and visibleReportActions checks only the actions that changed. Recomputing only the reports a write can affect already landed in main with Recompute only changed reports in visibleReportActions and sortedReportActions #106647.
  • React Compiler can memoize the list arrays, renderItem, and the row error callbacks, so a write to a report field the rows don't show no longer re-renders them.
  • Rows no longer subscribe to the report's transactions or to the text of a message being edited. Starting or stopping an edit re-renders only the edited row, not every row.
  • The composer ignores report fields it doesn't show, like lastReadTime and the last message, and useAncestors re-renders only when a report or action in the ancestor chain changes.
  • Mention name maps include only the reports and people a message mentions.
  • Sending a message finds the previous last visible action in one scan. Transaction matching, page lookup, and send telemetry no longer scan or sort per item.
  • Placeholder rows keep their identity, and no code mutates a cached Onyx action anymore.

Two behavior changes are intended. The skeleton decision now ignores hidden pay actions and surveys, like the rendered list. List rows also keep reportID, which ReportActionItem and ActionContentRouter read.

Measurements

I measured this branch again on 2026-11-17, after adding the sort cache, derived value, edit, composer, and useAncestors changes above. main is still 7bf05f5, which includes #106647 by twilight2294. That PR makes visibleReportActions and sortedReportActions recompute only the reports a write can affect, which was most of the improvement in my first measurements. The earlier numbers are archived at the end of this section.

The new Reassure scenario tests/perf-test/ReportScreenMessages.perf-test.tsx mounts the list and the composer on an account with a 500-message chat and 300 other chats. I ran it twice, with main first and then with this branch first.

Reassure scenario main This PR Change
JS time to send 10 messages 451 ms / 458 ms 283 ms / 279 ms -37% / -39%
JS time to receive 10 messages 509 ms / 506 ms 332 ms / 336 ms -35% / -34%
A heartbeat field of the report changes (existing) 146 ms 116 ms -21%
An unrelated transaction is written (existing) 97 ms 94 ms -4%, within Reassure's noise
One visible action is edited (existing) 147 ms 142 ms -4%, within Reassure's noise

The heartbeat and report name scenarios still render once more than on main, 28 times instead of 27.

The Sentry spans come from production web builds in Chrome with 4x CPU throttling, on an offline account with a 500-message chat and 1,000 other chats. Each build ran 12 interleaved sessions, and the first send of every session counts as a warm-up.

Span, web main median (P95) This PR median (P95) Change [95% CI]
ManualSendMessageVisible 276 ms (334 ms) 250 ms (294 ms) -9.6% [-16.6%, -6.3%]
OnyxDerivedCompute, summed per send 37 ms (48 ms) 35 ms (39 ms) no measurable change
ManualOpenReport, 500-message chat 675 ms (854 ms) 598 ms (714 ms) no measurable change

An A/A run of main against itself on the web had intervals of up to 10% for sending, so the faster send on the web is close to the noise.

The same flow ran on a Samsung Galaxy S10 5G with Android 12 and an iPhone 14 Pro with iOS 27.2.1, with Release HybridApp builds of main and this branch installed side by side. Both builds share the same native code and differ only in the JavaScript bundle. Each build ran 12 cold-launched runs interleaved as A, B, B, A. Every run restored the same seeded offline account, opened the 500-message chat, and sent 6 messages, and the first send of every run counts as a warm-up.

Span, Galaxy S10 main median (P95) This PR median (P95) Change [95% CI]
ManualSendMessageVisible 932 ms (977 ms) 602 ms (656 ms) -35.4% [-36.8%, -33.9%]
OnyxDerivedCompute, summed per send 73 ms (77 ms) 59 ms (67 ms) -19.2% [-20.3%, -17.4%]
ManualOpenReport, 500-message chat 741 ms (792 ms) 680 ms (747 ms) -8.3% [-11.7%, -5.0%]
Span, iPhone 14 Pro main median (P95) This PR median (P95) Change [95% CI]
ManualSendMessageVisible 405 ms (473 ms) 266 ms (305 ms) -34.2% [-34.9%, -33.2%]
OnyxDerivedCompute, summed per send 31 ms (35 ms) 25 ms (27 ms) -19.4% [-22.6%, -16.7%]
ManualOpenReport, 500-message chat 234 ms (238 ms) 208 ms (214 ms) -11.1% [-12.4%, -10.0%]

I marked both Android builds debuggable to copy the seeded account into them. That slows their Java code equally and doesn't affect Hermes.

An A/A run of main against itself on the Galaxy S10 showed no difference for any of the three spans, and its intervals stayed within 5%.

With the latest changes, sending a message takes 35% less time on the Galaxy S10 and 34% less on the iPhone. The derived work per send drops by 19% on both phones, and the 500-message chat opens 8% faster on the Galaxy S10 and 11% faster on the iPhone. Reassure measures 37% to 39% less JS time to send 10 messages and 34% to 35% less to receive them. In a Jest CPU profile of 10 sends, the deprecated sort cache in ReportAlternateTextUtils went from 38 ms to 3 ms, the largest single drop. On the web, sending is 10% faster, which is close to the noise there.

I didn't run the iOS simulator and the Android emulator again, because both phones were available. Their numbers from 2026-11-16 are in the archive below.

Second measurements, from 2026-11-16, before the latest changes

I rebased this branch on main and measured it again on 2026-11-16. Most of the first improvement came from #106647 by twilight2294, which merged on 2026-11-12. It makes visibleReportActions and sortedReportActions recompute only the reports a write can affect. This PoC carried the same change when I first measured it, against a main that didn't have it yet. The numbers below compare against main at 7bf05f5, which includes #106647.

The new Reassure scenario tests/perf-test/ReportScreenMessages.perf-test.tsx mounts the list and the composer on an account with a 500-message chat and 300 other chats. I ran it twice, with main first and then with this branch first.

Reassure scenario main This PR Change
JS time to send 10 messages 444 ms / 433 ms 430 ms / 419 ms -3% / -3%, within Reassure's noise
JS time to receive 10 messages 488 ms / 477 ms 446 ms / 426 ms -8% / -11%
A heartbeat field of the report changes (existing) 136 ms 107 ms -21%
An unrelated transaction is written (existing) 91 ms 89 ms -2%, within Reassure's noise
One visible action is edited (existing) 137 ms 137 ms no change

The heartbeat and report name scenarios render once more than on main, 28 times instead of 27.

The Sentry spans come from production web builds in Chrome with 4x CPU throttling, on an offline account with a 500-message chat and 1,000 other chats. Each build ran 12 interleaved sessions, and the first send of every session counts as a warm-up.

Span, web main median (P95) This PR median (P95) Change [95% CI]
ManualSendMessageVisible 273 ms (328 ms) 272 ms (326 ms) no measurable change
OnyxDerivedCompute, summed per send 37 ms (44 ms) 36 ms (44 ms) no measurable change
ManualOpenReport, 500-message chat 624 ms (740 ms) 632 ms (936 ms) no measurable change

The same flow ran on an iOS 27 simulator, an Android 15 emulator, and a Samsung Galaxy S10 5G with Android 12, with Release HybridApp builds of main and this branch installed side by side. Both builds share the same native code and differ only in the JavaScript bundle. Each build ran 12 cold-launched runs interleaved as A, B, B, A. Every run restored the same seeded offline account, opened the 500-message chat, and sent 6 messages, and the first send of every run counts as a warm-up. The simulator and the emulator run on the Mac's CPU, so only the change between builds matters there.

Span, iOS simulator main median (P95) This PR median (P95) Change [95% CI]
ManualSendMessageVisible 295 ms (326 ms) 281 ms (324 ms) -4.7% [-6.7%, -3.1%]
OnyxDerivedCompute, summed per send 24 ms (30 ms) 23 ms (25 ms) no measurable change
ManualOpenReport, 500-message chat 185 ms (215 ms) 191 ms (207 ms) no measurable change

One main run on the simulator stopped when the simulator shut down, so main has 11 runs there.

Span, Android emulator main median (P95) This PR median (P95) Change [95% CI]
ManualSendMessageVisible 408 ms (1,359 ms) 404 ms (1,851 ms) no measurable change
OnyxDerivedCompute, summed per send 26 ms (70 ms) 26 ms (118 ms) no measurable change
ManualOpenReport, 500-message chat 567 ms (1,743 ms) 606 ms (1,558 ms) no measurable change

Other work on the Mac slowed six emulator runs in a row, four of them on this branch. That raises both P95s, but not the medians.

Span, Galaxy S10 main median (P95) This PR median (P95) Change [95% CI]
ManualSendMessageVisible 938 ms (983 ms) 909 ms (956 ms) -3.1% [-4.4%, -2.0%]
OnyxDerivedCompute, summed per send 72 ms (78 ms) 75 ms (78 ms) +4.2% [+1.4%, +4.2%]
ManualOpenReport, 500-message chat 712 ms (775 ms) 643 ms (656 ms) -9.8% [-11.2%, -8.0%]

I marked both phone builds debuggable to copy the seeded account into them. That slows their Java code equally and doesn't affect Hermes.

On the web, the emulator, and the phone, an A/A run of main against itself showed no difference for any of the three spans. On the phone, its intervals reached 4.6%, so the faster send and the slower derived work there are close to the noise, while the 10% faster chat open is not.

With #106647 in main, the other changes in this PR gain much less. The Galaxy S10 opens the 500-message chat 10% faster and sends 3% faster, and the iOS simulator sends 5% faster. Reassure measures 8% to 11% less JS time to receive messages and 21% less when a heartbeat field changes. The web and the emulator show no measurable change.

First measurements, against main before #106647 merged

The new Reassure scenario tests/perf-test/ReportScreenMessages.perf-test.tsx mounts the list and the composer on an account with a 500-message chat and 300 other chats. I ran it twice, with main first and then with this branch first.

Reassure scenario main This PR Change
JS time to send 10 messages 794 ms / 698 ms 478 ms / 473 ms -40% / -32%
JS time to receive 10 messages 1,060 ms / 1,239 ms 536 ms / 464 ms -49% / -63%
A heartbeat field of the report changes (existing) 221 ms 114 ms -48%
An unrelated transaction is written (existing) 207 ms 101 ms -51%
One visible action is edited (existing) 237 ms 148 ms -38%

The Sentry spans come from production web builds in Chrome with 4x CPU throttling, on an offline account with a 500-message chat and 1,000 other chats. Each build ran 12 interleaved sessions, and the first send of every session counts as a warm-up.

Span main median (P95) This PR median (P95) Change [95% CI]
ManualSendMessageVisible 404 ms (616 ms) 324 ms (478 ms) -20% [-32%, -9%]
OnyxDerivedCompute, summed per send 106 ms (164 ms) 41 ms (61 ms) -61% [-63%, -57%]
ManualOpenReport, 500-message chat 1,012 ms (1,842 ms) 993 ms (1,877 ms) no measurable change

The same flow also ran on an iOS 27 simulator, with Release HybridApp builds of main and this branch installed side by side. Both builds share the same native code and differ only in the JavaScript bundle. Each build ran 12 cold-launched runs interleaved as A, B, B, A. Every run restored the same seeded offline account, opened the 500-message chat, and sent 6 messages, and the first send of every run counts as a warm-up. The simulator runs on the Mac's CPU, so only the change between builds matters.

Span, iOS simulator main median (P95) This PR median (P95) Change [95% CI]
ManualSendMessageVisible 653 ms (788 ms) 314 ms (397 ms) -51.8% [-53.1%, -50.8%]
OnyxDerivedCompute, summed per send 353 ms (362 ms) 22 ms (24 ms) -93.8% [-94.1%, -93.8%]
ManualOpenReport, 500-message chat 178 ms (205 ms) 180 ms (197 ms) no measurable change

Almost all of the 339 ms saved per send is derived-value work. On main, the simulator spends 353 ms of every send rebuilding the derived values, against 106 ms in throttled Chrome. An A/A run of main against itself showed no difference for sending or the derived work, while its chat-open times differed by up to 15%.

On an Android 15 emulator, with Release HybridApp builds and the same 12 interleaved runs per build:

Span, Android emulator main median (P95) This PR median (P95) Change [95% CI]
ManualSendMessageVisible 818 ms (961 ms) 426 ms (488 ms) -48.0% [-49.0%, -46.1%]
OnyxDerivedCompute, summed per send 399 ms (450 ms) 25 ms (29 ms) -93.7% [-93.9%, -93.4%]
ManualOpenReport, 500-message chat 527 ms (651 ms) 526 ms (589 ms) no measurable change

An A/A run of main against itself showed no difference for any of the three spans.

On a Samsung Galaxy S10 5G with Android 12, with Release HybridApp builds of both installed side by side and 12 interleaved runs per build:

Span, Galaxy S10 main median (P95) This PR median (P95) Change [95% CI]
ManualSendMessageVisible 2,186 ms (2,239 ms) 1,017 ms (1,088 ms) -53.5% [-54.3%, -52.6%]
OnyxDerivedCompute, summed per send 1,216 ms (1,249 ms) 72 ms (77 ms) -94.1% [-94.2%, -94.0%]
ManualOpenReport, 500-message chat 736 ms (778 ms) 676 ms (702 ms) -8.0% [-9.7%, -6.2%]

The derived-value work is 1,144 ms of the 1,169 ms saved per send. I marked both phone builds debuggable to copy the seeded account into them. That slows their Java code equally and doesn't affect Hermes. I dropped two main runs because the phone's lock screen interrupted them. An A/A run of main against itself showed no difference for any of the three spans, and every interval stayed within 2% of zero. That makes the faster chat open on this phone unlikely to be noise.

Reassure's render-only time while sending went up (193 ms to 245 ms, and 184 ms to 266 ms) while the total JS time fell, and the render count stayed the same.

Fixed Issues

$ #107911
PROPOSAL: https://expensify.slack.com/archives/C05LX9D6E07/p1795564470271989

Tests

  1. Open a chat with a few hundred messages.
  2. Send a message. Verify it appears at the bottom of the chat.
  3. Hover one of your older messages and click the pencil icon to edit it.
  4. Type a few characters. Verify only that message shows the editor.
  5. Press Enter. Verify the edited text shows.
  6. Open an expense report that has one expense.
  7. Add a comment. Verify the comment shows in the report.
  • Verify that no errors appear in the JS console

Offline tests

  1. Turn off the network.
  2. Open a chat with a few hundred messages.
  3. Send two messages. Verify both appear at the bottom of the chat, greyed out.
  4. Turn the network back on. Verify both messages post and stop being greyed out.

QA Steps

None. This proof of concept is for review of the approach and will be split into smaller PRs before anything merges.

  • 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 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 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 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 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).
  • 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

None. The list renders the same rows as before. This PR changes how they are computed, not how they look.

Council review

Rounds: 1

The scores rate the pipeline on main, before this PR.

Delegate Round 1
Claude Opus 5.5 4/10
GPT-6.1 Sol 6/10
Gemini 4 Argon 5.5/10
Grok 4.7 5/10
Apex 4/10

🤖 Generated with Claude Code

@codecov

codecov Bot commented Nov 12, 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 Δ
...equestReportView/MoneyRequestReportActionsList.tsx 97.36% <100.00%> (ø)
.../MoneyRequestReportView/MoneyRequestReportView.tsx 72.47% <100.00%> (ø)
...questReportView/useMoneyRequestReportPagination.ts 98.48% <100.00%> (ø)
src/hooks/useConciergeSidePanelReportActions.ts 86.95% <100.00%> (-0.15%) ⬇️
src/hooks/useExportActions.ts 73.68% <100.00%> (ø)
src/hooks/useLifecycleActions.tsx 77.86% <100.00%> (ø)
src/hooks/useLoadReportActions.ts 88.88% <100.00%> (ø)
src/hooks/useMarkAsRead.ts 98.08% <100.00%> (ø)
src/hooks/useMoneyReportHeaderStatusBar.ts 80.00% <100.00%> (+1.33%) ⬆️
src/hooks/usePaginatedReportActions.ts 97.22% <100.00%> (-0.15%) ⬇️
... and 41 more
... and 8 files with indirect coverage changes

chrispader and others added 2 commits November 16, 2026 17:11
Mounts the report list and composer on a large account and measures sending and receiving 10 messages, both as renders and as total JS time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Proof of concept. The list's data now passes through one named array per stage
(cachedActions, windowActions, reportViewActions, combinedActions, listActions,
visibleActions, listData), and every visibility rule is applied in
useReportActionsVisibility instead of being split across the model and the list.

It also removes work that ran on every message:
- All readers of a report share one sort per Onyx value instead of sorting it once each.
- visibleReportActions and sortedReportActions recompute only the reports a write
  can affect (from Expensify#106647) and keep their previous value when nothing changed, so
  Onyx skips the write and the notifications.
- React Compiler can now memoize the list arrays, renderItem, and the row error callbacks.
- Rows no longer subscribe to the report's transactions or to the edit text.
- Transaction matching, page lookup, and send telemetry no longer scan or sort per item.
- Placeholder rows keep their identity, and no Onyx-cached action is mutated anymore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chrispader
chrispader force-pushed the @chrispader/perf/report-actions-pipeline-poc branch from 53eec38 to b56f872 Compare November 16, 2026 16:12
chrispader and others added 3 commits November 17, 2026 12:33
… list

- Rows learn whether they show the editor from a store, so starting or stopping an edit re-renders one row instead of every row.
- Only the created row mounts ShowPreviousMessagesButton, and only ACH payment rows read the report's actions for their expected date.
- The list model reads each value once and passes it down, and builds the canonical index map only when system messages are collapsed.
- getLastVisibleAction checks visibility only for actions newer than its current pick, and sending reuses that result instead of scanning twice.
- The deprecated sorted actions cache sorts only the reports a write can change, instead of every report on every write.
- visibleReportActions and sortedReportActions skip report writes that change none of their inputs, and visibility checks only the actions that changed.
- useAncestors selects only the parent chain, so a write anywhere else doesn't re-render its callers.
- The composer maps names only for the rooms and people a message mentions, reads the report without the fields every message changes, and looks for a one-expense thread only in reports that can have one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Take main's lazy mention name maps (Expensify#106086) and one-pass expense
matching (Expensify#107294), which already hold the PoC's versions of both.
Keep the incremental deprecated sort cache without the one-expense
thread merge that main removed, recheck mention whispers when a report
moves to another policy, and use the PoC's stage names in main's new
code and tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep main's useParentReportAction in the report action context menu
with the PoC's windowActions name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chrispader chrispader changed the title [No QA] PoC: Simplify the report actions list pipeline and remove repeated work PoC: Simplify the report actions list pipeline and remove repeated work Nov 24, 2026
@chrispader

Copy link
Copy Markdown
Contributor Author

Note

Chris's AI sidekick here (Codex). 🤖

Closing this PoC with broad support for the direction. The work is split into smaller PRs so each change can be reviewed and merged separately. The rollout plan tracks their scope, order, and dependencies. This PR remains the reference implementation.

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.

1 participant