Skip to content

[NoQA] Remove functions used only by tests - #107234

Merged
roryabraham merged 3 commits into
Expensify:mainfrom
Eskalifer1:remove-test-only-functions
Nov 18, 2026
Merged

roryabraham merged 3 commits into
Expensify:mainfrom
Eskalifer1:remove-test-only-functions

Conversation

@Eskalifer1

@Eskalifer1 Eskalifer1 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Step 6 of the plan in #106552.

Problem
Some exported functions are called only from tests. The default knip run counts tests as users, so it never reports them, and they stay in the code and in the reader's way long after the last real caller is gone.

Solution
The list comes from running knip with only the app entry points, then each function was checked by hand: no import, platform variant, dynamic use or use in Mobile-Expensify, and no open PR or issue that plans to call it. Functions that only look unused because their feature is still in development (Flat Nav, the fraud review flow, Travel, AgentZero, the agent rules page), cancelSpansByPrefix and the getRegisteredGuards test accessor are left in place. The other 20 are removed together with the tests that only covered them.

Result
The functions are gone and no new findings appear.

main this PR change
Unused exports and types in a knip run without tests as users 136 120 -16
Unused files in the same run 19 17 -2
Files changed 38
Lines +55 / -1372

Of the 20 removed functions, 16 are exports knip reports, 2 are whole files (the two hooks), and 2 sit in .native and .web platform files, which knip does not report.

Removed functions
Function File Added Last use removed
writeLiveSingleRHPWidth src/libs/Navigation/helpers/singleRHPWidth/index.native.ts #104573 (2026-10-27) #106105 (2026-11-10)
callback src/libs/actions/InputFocus/index.web.ts #29073 (2023-10-13) #54858 (2025-01-17)
shouldCalculateBillNewDot src/libs/SubscriptionUtils.ts #59070 (2025-04-16) #92917 (2026-06-23)
getMergeATSFilterValues src/libs/merge/RecruitingUtils.ts #101236 (2026-09-24) #103598 (2026-10-15)
shouldShowRecruitingConnectionError src/libs/merge/RecruitingUtils.ts #99585 (2026-09-01) never used in the app
useCopySelectionHelper src/hooks/useCopySelectionHelper.ts #22808 (2023-07-18) #97277 (2026-10-14)
usePaginatedData src/hooks/usePaginatedData.ts #88452 (2026-06-10) #95778 (2026-08-10)
formatRequireItemizedReceiptsOverText src/libs/CategoryUtils.ts #73939 (2026-01-26) #98662 (2026-09-11)
lastItem src/libs/CollectionUtils.ts #536 (2020-09-25) #31288 (2023-11-14)
formatCurrentUserToAttendee src/libs/IOUUtils.ts #48008 (2024-09-05) #96526 (2026-08-07)
getThreadReportIDsForTransactions src/libs/MoneyRequestReportUtils.ts #58903 (2025-03-31) #97906 (2026-08-18)
isValidMerchant src/libs/MoneyRequestUtils.ts #89166 (2026-05-14) #103678 (2026-10-19)
getTitleFieldFromRNVP src/libs/ReportTitleUtils.ts #70817 (2025-09-23) #95419 (2026-07-07)
isExpensifyOnlyParticipantInReport src/libs/ReportUtils.ts #29012 (2023-11-27) #30019 (2023-11-01)
isReportFieldNameExisting src/libs/WorkspaceReportFieldUtils.ts #75011 (2025-12-23) #101470 (2026-09-21)
verifyFileFormat src/libs/fileDownload/FileUtils.ts #46025 (2024-08-06) #102057 (2026-10-23)
areAllExpensifyCardsShipped src/selectors/Card.ts #81363 (2026-02-05) #97252 (2026-08-06)
personalDetailsDisplayNameSelector src/selectors/PersonalDetails.ts #91416 (2026-05-29) #102059 (2026-09-30)
reportByIDsSelector (default export) src/selectors/ReportAttributes.ts #70862 (2025-09-23) #97111 (2026-08-18)
sessionEmailAndAccountIDSelector src/selectors/Session.ts #83299 (2026-03-17) #104749 (2026-10-26)

isExpensifyOnlyParticipantInReport was added by the TypeScript migration after its last caller had already been removed.

Fixed Issues

$ #106552
PROPOSAL:

Tests

N/A, no user-visible change

  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

N/A

  • 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

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@Eskalifer1

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T12:22:34.230181Z e4d8df6 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.

@Eskalifer1

Copy link
Copy Markdown
Contributor Author

@MelvinBot Review this PR and additionally check if every function that was deleted is really "dead and not used especially for tests or are developed now or recent and not used in any open(or future planned) PRs

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: e4d8df62f4

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

Review result

All 20 functions have no current production callers in App, but I found one active-PR overlap. The PR’s claim that none overlap ongoing development needs correcting before merge.

Reviewed commit e4d8df6.

Findings

  1. Coordinate the useCopySelectionHelper deletion with active clipboard work.
    The open Keep copied chat text consistent across paste destinations PR modifies both this hook and its tests. Its hook implementation directly overlaps these deletions, creating a modify/delete integration conflict. That PR does not introduce a production caller, so this is coordination work—not proof the hook must remain.

  2. Preserve useful shortcut coverage separately.
    The deleted hook test:65–83 explicitly verifies subscription arguments and unsubscribe-on-unmount for the surviving useKeyboardShortcut.ts:52–74. I found no equivalent surviving assertion. Move those checks into a dedicated shortcut-hook test; retaining the unused copy hook is unnecessary.

Every-function audit

Checked production imports, surviving tests/mocks, module paths, default-import aliases, namespace access and platform variants.

Results for all 20 deletions
Function Current-use conclusion
writeLiveSingleRHPWidth Unused native stub; recent RHP work replaced the old abstraction.
InputFocus callback Unused export; unrelated callback properties remain unaffected.
shouldCalculateBillNewDot Only removed tests called it; same-named production locals are independent.
getMergeATSFilterValues Only removed tests called it; filter behavior intentionally changed.
shouldShowRecruitingConnectionError Only removed tests called it.
useCopySelectionHelper No production caller, but actively modified by the clipboard PR above.
usePaginatedData Its dedicated deleted test was its only importer.
formatRequireItemizedReceiptsOverText Only removed tests called it.
lastItem Surviving unread-indicator test callers are migrated to an equivalent local helper.
formatCurrentUserToAttendee Only removed tests called it.
getThreadReportIDsForTransactions Only removed tests called it.
isValidMerchant Production already uses the underlying validation functions directly.
getTitleFieldFromRNVP Only tests used it; its removed Onyx subscription populated a private cache unused by surviving code.
isExpensifyOnlyParticipantInReport Only surviving test-setup filters used it; those filters are updated.
isReportFieldNameExisting Only removed tests called this wrapper; underlying lookup tests remain.
verifyFileFormat Production already uses underlying helpers; tests are migrated to exercise them directly.
areAllExpensifyCardsShipped Only removed tests called it.
personalDetailsDisplayNameSelector Only removed tests called it.
reportByIDsSelector No production default importer, including renamed imports.
sessionEmailAndAccountIDSelector Only removed tests called it.

No broken surviving consumer was found.

Active/recent-work checks

  • Enumerated 732 open PRs and inspected 114 selected PR diffs, including affected-file matches, related feature work and large PRs. Searched indexed issues for all 20 names.
  • Validated several recent removals as intentional replacements, including RHP resizing, recruiting filters, merchant validation, file-format handling and the session selector.
  • Found stale verifyFileFormat references in open stacked branches, but no established intentional new caller in their focused changes.

Limits: This was not an exhaustive checkout of every open branch. Mobile-Expensify access returned HTTP 404, so external consumers remain unverified. Unpublished future plans cannot be ruled out.

Validation

26 focused Jest suites passed: 1,133 tests passed, 2 skipped. Some suites emitted non-failing warnings. CI’s typecheck, test shards and knip comparison also passed; independent approval remains outstanding. Browser testing was not performed.

Recommendation: Reconcile the clipboard PR overlap and preserve the shortcut assertions. Otherwise, the App-side evidence supports these removals; I found no current runtime regression.


view run

@Eskalifer1

Copy link
Copy Markdown
Contributor Author

but I found one active-PR overlap

The hook has had no caller since #97277 replaced it with useCopySelectionEvent. #106742 (a draft) edits the hook and its test, but only to apply the same getClipboardText to formatClipboardContent swap it makes in useCopySelectionEvent. It does not add a call to the hook, so I'm keeping the deletion.

Whichever PR lands second drops its hunk for this hook and its test (or rebases onto the deletion). I'll leave a note on #106742 so its author knows the hook is dead and doesn't need to be kept in sync.

The two shortcut assertions in the deleted test (subscribe arguments and unsubscribe on unmount) checked what this hook passed to useKeyboardShortcut for the copy shortcut. They go away with the hook. A dedicated test for useKeyboardShortcut itself would be a separate change, so I'm not adding one here.

@Eskalifer1
Eskalifer1 marked this pull request as ready for review November 18, 2026 12:07
@Eskalifer1
Eskalifer1 requested review from a team as code owners November 18, 2026 12:07
@expensify-chore-bot
expensify-chore-bot Bot requested review from daledah and removed request for a team November 18, 2026 12:07
@expensify-chore-bot

Copy link
Copy Markdown

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

@expensify-chore-bot
expensify-chore-bot Bot requested review from trjExpensify and removed request for a team November 18, 2026 12:07
@Eskalifer1

Copy link
Copy Markdown
Contributor Author

Sorry for the noise @daledah, this issue doesn't require C+ review

@trjExpensify

Copy link
Copy Markdown
Contributor

PR doesn’t need product input as a refactor PR. Unassigning and unsubscribing myself.

@trjExpensify
trjExpensify removed their request for review November 18, 2026 18:43

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

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 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 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 and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 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 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
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari

@roryabraham
roryabraham merged commit cc19dae into Expensify:main Nov 18, 2026
46 of 47 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

🚧 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.42-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed — this PR removes unused code and associated tests without changing user-facing features, workflows, labels, or beta availability, so no existing article becomes incorrect.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/marcaaron in version: 9.5.42-2 🚀

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.

5 participants