Skip to content

[No QA] Disallow manual memoization in compiled React code - #104522

Merged
roryabraham merged 20 commits into
mainfrom
rory/disallow-manual-memoization-104514
Oct 26, 2026
Merged

roryabraham merged 20 commits into
mainfrom
rory/disallow-manual-memoization-104514

Conversation

@roryabraham

@roryabraham roryabraham commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

React Compiler already owns memoization in compiled components and hooks. Manual wrappers are unnecessary and can prevent the compiler from improving memoization.

  • Add rulesdir/no-manual-memoization, enforced only when both Babel and OXC fully compile and memoize the file. Keep the useCallback exception for React Navigation's useFocusEffect.
  • Remove 2,351 redundant React.memo, useMemo, and useCallback wrappers, including the eight files whose compilation failed solely because of existing manual memoization. Those eight now compile with both compilers. Files with unrelated compiler failures remain out of scope.
  • Derive values directly in render without introducing IIFEs. Keep small compiled projection hooks where stable result identities are required by downstream effects and lists.
  • Delete the redundant AI review rule, .claude/skills/app-coding-standards/rules/clean-react-0-compiler.md, and its references.

AI Tests

  • Passed full-repository ESLint (single process with increased heap, --no-cache), changed-file lint, type checking, Babel/OXC compiler compliance, formatting, spelling, and the Storybook smoke test.
  • Passed the Bun tooling suite and 42 focused compiler/lint pipeline tests.
  • Jest coverage across resumed runs: 1,940 suites passed and one suite was skipped. Four assertions in SentryHtmlTreeAsStringTest.ts fail identically in the original checkout; this dependency-patch issue is unchanged and out of scope. Worktree-only Jest resolution overrides were used for shared dependencies; no repository Jest configuration was changed.
  • Focused runtime coverage passed: search snapshot reference stability, all 41 expense-confirmation tests, and all 22 navigation tests after the review fix. The new lazy-placeholder test fails before the fix and passes after it.
  • Manual browser/native/offline QA has not been performed; this PR remains a draft for the human co-author to complete that verification.
Main merge revalidation (2026-10-21)
  • Merged e8dad8b4beb in the existing worktree and resolved 30 conflicted files, preserving upstream behavior and this PR's memoization removal.
  • Passed full-repository lint through bun ./scripts/lint/index.ts --no-cache, changed-file lint, type checking, Babel/OXC compiler compliance, repository-wide formatting, changed-file spelling, the Storybook smoke test, all 658 Bun tests, and 152 focused Jest tests across nine suites. All 30 conflicted files also pass focused lint; an AST comparison confirms all 61 upstream memoized callbacks retain their behavior.
  • The full Jest attempt exceeded its 120-second limit after encountering 24 ESLint RuleTester failures in NoDirectPersonalDetailsListRuleTest.ts (Cannot assign to read only property '__private_3_steps'). The same failures reproduce in the existing baseline worktree at bc54f602df7; the test, rule, transformer, Jest configuration, and dependency lockfile are unchanged from current main.
  • Browser/native/offline QA was not repeated; no web dev server is running.
Main merge revalidation (2026-10-26)
  • Merged f386f2399cf in the existing worktree and resolved eight conflicted files, retaining the latest main behavior without restoring redundant manual memoization.
  • Passed 139 targeted Jest tests across seven suites and 43 Bun memoization/lint-pipeline tests. All eight resolved files pass focused lint, formatting, and the shared Babel/OXC memoization check.
  • Branch-wide Babel/OXC compiler compliance passed. Branch-wide changed-file lint reports type-resolution errors from the stale local camera/Onyx dependencies described below.
  • Full type checking is blocked by stale shared local dependencies: react-native-vision-camera is installed at 4.7.2 (requires 5.2.3), and react-native-onyx is installed at 3.0.117 (requires 3.0.119). Changed-file spelling reports the existing recognises typo in tests/unit/AccountingConnectionConfirmationTest.tsx:219, which is identical to main.
  • Browser/native/offline QA was not repeated.
JavaScript action build verification (2026-10-26)
  • Enabled esbuild's preserveSymlinks option so shared worktree dependencies produce the same module paths as a clean CI install. Rebuilt 25 action bundles; their only changes are dependency paths from ../../App/node_modules/ to node_modules/.
  • A CI rerun exposed an additional stale local dependency: awesome-phonenumber 5.4.0 was installed instead of the locked 6.11.0. Rebuilt the two affected bundles with 6.11.0 and the repository's existing patch, without changing the shared dependency install.
  • Passed .github/scripts/verifyActions.sh with a repeat rebuild producing no diff, focused lint, formatting, spelling, and npm run typecheck -- tsconfig.node.json.
Export dropdown review fix (2026-10-26)
  • Verified the review finding with the real split button, policy preference action, and Onyx subscription: selecting the other option updated the preference, reordered the array, and caused the next main-button press to execute the opposite action. All three new regression cases failed before the fix.
  • Kept the export options in a fixed order and selected the remembered preference through defaultSelectedIndex, without changing the shared dropdown or restoring manual memoization.
  • Passed all 10 tests across the export-selection, export-confirmation, and shared-dropdown suites; focused lint, formatting, spelling, and the Babel/OXC memoization check passed. Full lint/type checking still reports the existing stale local camera/Onyx dependency errors, with no diagnostics in either changed file. Browser QA was not run because no dev server is running.
Latest main merge revalidation (2026-10-26)
  • Merged a611f4ca31d in the existing worktree, resolving five conflicts while retaining the latest new-report and workspace-task completion behavior without restoring manual memoization. The export-selection review fix and its tests are unchanged.
  • Passed 87 targeted tests across seven suites. All five resolved files pass focused lint, formatting, spelling, and the shared Babel/OXC memoization check. Action-build verification also passes with no rebuild diff.
  • Full type checking remains blocked by the existing stale local camera/Onyx dependencies, with no diagnostics in the resolved files. Branch-wide lint reports 12 type-resolution errors in the camera hook and unchanged upstream web-server/Cloudflare tooling files; none are in the five resolved files. The branch-wide Babel/OXC compiler check passed for all 1,025 changed React files. Browser/native/offline QA was not repeated.
Conflict resolution and ESLint repair (2026-10-26)
  • Merged e731b9b7a9d, resolving the two search-owner/per-diem conflicts while preserving upstream cardholder resolution and per-diem error handling without restoring manual memoization. The export-selection fix is unchanged.
  • Reproduced all 10 errors from the failed CI ESLint job: Expo's environment index signature inferred process.env.TZ as any in the date/transaction tests. Added the optional string declaration in src/types/env.d.ts; both affected test files now pass cache-free lint without casts or suppressions.
  • Refreshed stale camera, Onyx, Node, and Bun dependencies only in this worktree to the lockfile versions, preserving the previous packages separately and leaving the shared install untouched. Full type checking now passes.
  • Passed 665 targeted tests across seven suites, branch-wide Babel/OXC compliance for 941 changed React files, focused cache-free lint, formatting, spelling, and action-build verification. A cache-free full-repository lint run is in progress because the existing lint cache retains obsolete camera diagnostics. Browser/native/offline QA was not repeated.

Fixed Issues

$ #104514

Tests

Relying primarily on Applause regression tests.

  • Verify that no errors appear in the JS console

Offline tests

Same as tests.

QA Steps

None - relying on regression 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 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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@roryabraham
roryabraham requested a review from a team October 20, 2026 23:53
@melvin-bot

melvin-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

…memoization-104514

# Conflicts:
#	src/pages/ReportSubmitToContent.tsx
#	src/pages/workspace/rules/FlagForReviewRules/FlagForReviewRulePageBase.tsx
@codecov

codecov Bot commented Oct 21, 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 Δ
src/DeepLinkHandler.tsx 94.02% <100.00%> (ø)
...ponents/ActiveElementRoleProvider/index.native.tsx 100.00% <100.00%> (ø)
src/components/AddPaymentCard/PaymentCardForm.tsx 91.66% <100.00%> (ø)
src/components/ApproverSelectionList.tsx 95.83% <100.00%> (-0.17%) ⬇️
...nts/Attachments/AttachmentCarousel/Pager/index.tsx 100.00% <100.00%> (ø)
...omponents/Attachments/AttachmentCarousel/index.tsx 90.00% <100.00%> (-0.25%) ⬇️
...ttachments/AttachmentCarousel/useCarouselArrows.ts 92.30% <100.00%> (-0.55%) ⬇️
...ments/AttachmentView/AttachmentViewImage/index.tsx 87.50% <ø> (ø)
...nts/AttachmentView/AttachmentViewPdf/index.ios.tsx 0.00% <ø> (ø)
...chments/AttachmentView/AttachmentViewPdf/index.tsx 0.00% <ø> (ø)
... and 282 more
... and 512 files with indirect coverage changes

Track effect dependencies with the names key instead of a transient
array. Derive requested names inside the effect so resolving a cold
asset load does not restart it on every render.
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

This comment has been minimized.

…memoization-104514

# Conflicts:
#	src/components/LHNOptionsList/LHNOptionsList.tsx
#	src/components/LHNOptionsList/OptionRowLHN/OptionRowLHNData.tsx
#	src/components/MapView/MapView.tsx
#	src/components/MapView/MapViewImpl.web.tsx
#	src/components/Modal/ReanimatedModal/Backdrop/index.web.tsx
#	src/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx
#	src/components/MoneyRequestReportView/useMoneyRequestReportSortedTransactions.ts
#	src/components/MultiGestureCanvas/useCanvasPinchGesture.ts
#	src/components/MultiGestureCanvas/useCanvasTapGestures.ts
#	src/components/PopoverProvider/index.tsx
#	src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx
#	src/components/Search/SearchAutocompleteList.tsx
#	src/components/Search/SearchList/BaseSearchList/index.native.tsx
#	src/components/Search/SearchList/BaseSearchList/index.tsx
#	src/components/Search/SearchRouter/SearchRouter.tsx
#	src/components/Search/hooks/useSearchSnapshot.ts
#	src/components/TagPicker/index.tsx
#	src/hooks/useOriginalReportID.ts
#	src/pages/EnablePayments/Pay/Onfido/OnfidoStep.tsx
#	src/pages/RoomDescriptionPage.tsx
#	src/pages/Search/SearchMoneyRequestReportPage.tsx
#	src/pages/inbox/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx
#	src/pages/iou/request/step/DynamicIOURequestStepTag.tsx
#	src/pages/iou/request/step/IOURequestEditReportCommon.tsx
#	src/pages/media/AttachmentModalScreen/AttachmentModalBaseContent/index.tsx
#	src/pages/media/AttachmentModalScreen/routes/report/ReportAddAttachmentModalContent/index.tsx
#	src/pages/workspace/WorkspaceMembersPage.tsx
#	src/pages/workspace/expensifyCard/WorkspaceExpensifyCardListPage.tsx
#	src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx
#	src/pages/workspace/tags/WorkspaceTagsPage.tsx
React Navigation warns when useFocusEffect gets an unmemoized callback.
Also let the lint rule allow useCallback for useFocusEffect imported from @react-navigation/core.
@roryabraham

Copy link
Copy Markdown
Contributor Author

Regression tests completed with no issues found 🎉

@roryabraham roryabraham changed the title Disallow manual memoization in compiled React code [No QA] Disallow manual memoization in compiled React code Oct 26, 2026
@roryabraham
roryabraham marked this pull request as ready for review October 26, 2026 19:25
@roryabraham
roryabraham requested review from a team and Julesssss as code owners October 26, 2026 19:25
@roryabraham
roryabraham requested a review from mountiny October 26, 2026 19:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 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 ✅ Completed 2026-10-26T19:32:58.374528Z 10e49e9 Draft marked ready
ℹ️ 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.

@melvin-bot

melvin-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

@truph01 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 review from JmillsExpensify and removed request for a team October 26, 2026 19:25

@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: 10e49e9c1d

ℹ️ 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/iou/request/step/IOURequestStepConfirmation/index.tsx
Comment thread src/components/ReportActionItem/ExportWithDropdownMenu.tsx Outdated
@roryabraham
roryabraham requested a review from a team as a code owner October 26, 2026 19:56
@melvin-bot
melvin-bot Bot requested review from Gonals and removed request for a team October 26, 2026 19:56
@melvin-bot

melvin-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

@Gonals 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]

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

No product review required on this one.

mountiny
mountiny previously approved these changes Oct 26, 2026

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

regression testing successfully completed, there are conflicts

Expo's environment index signature leaves TZ typed as any. Declare its optional string type so timezone save/restore tests pass ESLint without casts or suppressions.
@roryabraham
roryabraham merged commit 5cb8254 into main Oct 26, 2026
44 of 47 checks passed
@roryabraham
roryabraham deleted the rory/disallow-manual-memoization-104514 branch October 26, 2026 23:41
@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

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

@github-actions

Copy link
Copy Markdown
Contributor

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/roryabraham in version: 9.5.24-1 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed. This PR is an internal refactor that removes manual memoization and adds a lint rule, so no feature, label, or workflow changes for users, and no article sentence becomes incorrect.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.5.24-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