Skip to content

perf: add selectors to derived hooks, export IOU getters#87081

Closed
rinej wants to merge 2 commits into
Expensify:mainfrom
callstack-internal:decompose-scan-pr1-selectors-getters
Closed

perf: add selectors to derived hooks, export IOU getters#87081
rinej wants to merge 2 commits into
Expensify:mainfrom
callstack-internal:decompose-scan-pr1-selectors-getters

Conversation

@rinej

@rinej rinej commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

This is PR 1 of 5 in the IOURequestStepScan decomposition series (see #85571 for the full split plan).

Adds Onyx selectors to derived hooks to prevent full-collection re-renders:

  • useReportIsArchived: uses isArchivedReport as selector for stable boolean output
  • useDefaultExpensePolicy: extracts getSingleGroupPolicyID selector, replaces collection iteration with selector + per-key lookup
  • usePolicyForMovingExpenses: extracts getPolicyQualificationResult selector returning only IDs and flags
  • useReportAttributes: adds useReportAttributesByID for single-report lookups with cheap deep comparison

Also exports two getter functions from IOU actions (getAllTransactionDrafts, getAllReportNameValuePairs) needed by downstream variant components.

No user-visible behavior changes — return types and values are preserved.

Fixed Issues

$ #85583

Tests

  • Verify that no errors appear in the JS console
  • Verify existing IOU request flows work unchanged (create expense, edit receipt, split bill)
  • Verify expense policy auto-selection still works correctly

Offline tests

N/A — no offline behavior changes

QA Steps

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 turned off my network connection and tested it while offline
    • I tested this PR with a High Traffic account against the staging or production API
  • 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
  • I followed proper code patterns
  • 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 verified all code is DRY
  • I verified any variables that can be defined as constants are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly

@rinej rinej closed this Apr 3, 2026
@codecov

codecov Bot commented Apr 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/hooks/usePolicyForMovingExpenses.ts 93.47% <100.00%> (+8.62%) ⬆️
src/hooks/useReportIsArchived.ts 100.00% <100.00%> (ø)
src/hooks/useReportAttributes.ts 0.00% <0.00%> (ø)
src/libs/actions/IOU/index.ts 75.30% <66.66%> (+2.16%) ⬆️
src/hooks/useDefaultExpensePolicy.tsx 62.50% <53.84%> (+22.50%) ⬆️
... and 542 files with indirect coverage changes

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