Skip to content

refactor: extract useMoneyRequestReportColumns and useMoneyRequestReportLayout - #101200

Merged
mountiny merged 7 commits into
Expensify:mainfrom
callstack-internal:decompose/money-request-report-transactions-b2-v2
Sep 21, 2026
Merged

mountiny merged 7 commits into
Expensify:mainfrom
callstack-internal:decompose/money-request-report-transactions-b2-v2

Conversation

@sosek108

@sosek108 sosek108 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

refactor: extract useMoneyRequestReportColumns and useMoneyRequestReportLayout

Explanation of Change

This is PR 8 of a 10-PR stack decomposing the MoneyRequestReport list components (MoneyRequestReportActionsList / MoneyRequestReportTransactionList) into focused hooks and presentational sub-components (issue #99919, superseding drafts #99307 and #99417).

This slice extracts the transaction table's column derivation and the report-layout (group-by) selection into dedicated hooks.

image

Fixed Issues

$ #99919
PROPOSAL:

Tests

  1. Open an expense report with transactions — verify the transaction table renders the same columns as before (amount, date, merchant, etc.)
  2. Add a transaction dated in a previous year — verify the date column widens to show the year
  3. Open the "Group by" dropdown — pick Category, Tag, and None — verify the grouping and the dropdown label update accordingly, with no flicker of the label through a default value
  4. Narrow the window until the table is wider than the viewport — verify the table gets its own horizontal scroller
  5. Open an IOU report — verify the "Columns" customization button is hidden
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline and change the "Group by" selection — verify the grouping applies immediately and survives going back online
  2. Go offline and add an expense — verify the table columns still derive correctly from the optimistic transaction

QA Steps

  1. Open an expense report with transactions — verify the transaction table renders the same columns as before (amount, date, merchant, etc.)
  2. On a report with company-card (non-reimbursable) spend, verify the Reimbursable column shows; on a workspace with billable expenses enabled, verify the Billable column shows
  3. Add a transaction dated in a previous year — verify the date column widens to show the year
  4. Open the "Group by" dropdown — pick Category, Tag, and None — verify the grouping and the dropdown label update accordingly, with no flicker of the label through a default value
  5. Narrow the window until the table is wider than the viewport — verify the table gets its own horizontal scroller
  6. Open an IOU report — verify the "Columns" customization button is hidden

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
Android: mWeb Chrome
iOS: Native
Nagranie.z.ekranu.2026-09-17.o.12.16.13.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
Nagranie.z.ekranu.2026-09-17.o.12.07.45.mov

… decompose/money-request-report-transactions-b2-v2
@codecov

codecov Bot commented Sep 17, 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/libs/SearchUIUtils.ts 71.06% <100.00%> (+0.02%) ⬆️
...pages/settings/Report/ReportDetailsColumnsPage.tsx 82.35% <100.00%> (-1.44%) ⬇️
...stReportView/MoneyRequestReportTransactionList.tsx 0.41% <0.00%> (+0.05%) ⬆️
...eyRequestReportView/useMoneyRequestReportLayout.ts 0.00% <0.00%> (ø)
...yRequestReportView/useMoneyRequestReportColumns.ts 0.00% <0.00%> (ø)
... and 10 files with indirect coverage changes

@sosek108
sosek108 marked this pull request as ready for review September 18, 2026 07:13
@sosek108
sosek108 requested review from a team as code owners September 18, 2026 07:13
@melvin-bot

melvin-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

@suneox 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 request for a team September 18, 2026 07:13
@suneox

suneox commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

I'll take a look at this pr soon

@joekaufmanexpensify

Copy link
Copy Markdown
Contributor

No product review needed.

@joekaufmanexpensify
joekaufmanexpensify removed their request for review September 18, 2026 19:22
@suneox

suneox commented Sep 19, 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
CleanShot.2026-09-19.at.13.32.46.2.mp4
Android: mWeb Chrome
CleanShot.2026-09-19.at.13.32.46.mp4
iOS: HybridApp
CleanShot.2026-09-19.at.13.46.35.4.mp4
iOS: mWeb Safari
CleanShot.2026-09-19.at.13.42.55.3.mp4
MacOS: Chrome / Safari
CleanShot.2026-09-19.at.13.22.13.1.mp4
CleanShot.2026-09-19.at.13.59.56.1.mp4


const REPORT_DETAILS_CUSTOM_COLUMNS = Object.values(CONST.SEARCH.REPORT_DETAILS_CUSTOM_COLUMNS);

function isReportDetailsCustomColumn(column: string): column is SearchCustomColumnIds {

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.

NAB: This function is duplicated in ReportDetailsColumnsPage; we can extract it and reuse

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, extracted to SearchUIUtils

@sosek108

Copy link
Copy Markdown
Contributor Author

@suneox I've resolved conflicts. This is ready for finish of your review

@suneox suneox 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 logic changes & no measurable perf impact, LGTM

Perf A/B check Reassure, merge-base `08bc847` vs PR head `2c13e8a`, same machine, sequential runs:
Test (MoneyRequestReportActionsList.perf-test) Base (ms) PR (ms) Δ Renders
render, 500 actions + 10 transactions 25.9 25.1 −3.4% 6 → 6
render, 500 actions + 100 transactions 29.5 29.1 −1.4% 6 → 6
re-render on transaction change 86.1 84.2 −2.2% 12 → 12
re-render on new report action 91.7 89.3 −2.6% 12.10 → 12.10
re-render on unrelated report update 93.2 97.0 +4.1% 16 → 16

@melvin-bot
melvin-bot Bot requested a review from mountiny September 21, 2026 08:26

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

Straightforwards, thanks

@mountiny
mountiny merged commit 1dc6e72 into Expensify:main Sep 21, 2026
36 of 38 checks passed
@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

🚧 mountiny 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/mountiny in version: 9.4.91-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site changes required — no draft PR created

This PR is a pure internal refactor. It moves existing logic out of MoneyRequestReportTransactionList into two new hooks and hoists one type guard into SearchUIUtils. Nothing user-facing changes: no new feature, no removed feature, no changed label, button, menu item, or copy string.

Because nothing on the help site is now inaccurate, there is nothing to document, so I did not open a draft PR.

What I checked

The five changed files, and why each is docs-neutral:

File Change User-facing?
src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx Column derivation and group-by state moved out into hooks No — same values, same render output
src/components/MoneyRequestReportView/useMoneyRequestReportColumns.ts New hook, lifted verbatim from the component No
src/components/MoneyRequestReportView/useMoneyRequestReportLayout.ts New hook, lifted verbatim, keeps the same click latch No
src/libs/SearchUIUtils.ts:4288 isReportDetailsCustomColumn type guard added and exported No
src/pages/settings/Report/ReportDetailsColumnsPage.tsx:44 Uses the shared type guard instead of a local copy No

The one change that is not byte-identical logic: the saved column list is now narrowed with .filter(isReportDetailsCustomColumn) instead of an as SearchCustomColumnIds[] cast. In practice this is a no-op, because the only writer of that NVP is the Columns page, which already writes values drawn from the same REPORT_DETAILS_CUSTOM_COLUMNS set. It changes type safety, not which columns you see.

Existing help site coverage stays accurate. The group-by flow this PR touches is documented in docs/articles/new-expensify/reports-and-expenses/Using-Reports-in-New-Expensify.md:92-103, under How to group expenses by category or tag using Report Layout. It documents Group by category, Group by tag, and Don't group reached from the More icon — all preserved unchanged by this PR. The Columns page copy in ReportDetailsColumnsPage.tsx is untouched too.

If you expected a behavior change here that I missed, reply with @MelvinBot <what changed> and I'll re-scope it.


Note: there is no help site PR to link, since this refactor requires no docs changes. The requested sign-off line follows for completeness.

@sosek108, 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.91-3 🚀

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