Repository navigation
[NoQA] Fix import/no-cycle - part 18 - #103203
roryabraham merged 29 commits into
Conversation
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.
|
478fb46 to
3adf64d
Compare
…hods BankAccounts imports the helper from its leaf module, so the re-export in PaymentMethods is dead. Fixes the knip 'exports' regression.
|
@thelullabyy 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] |
dylanexpensify
left a comment
There was a problem hiding this comment.
Looks good from a product perspective 👍
…ure-helper-leaves-v1 # Conflicts: # src/libs/DistanceRequestUtils.ts # src/pages/workspace/distanceRates/PolicyCommuterExclusionsPage.tsx
|
@MelvinBot Deep review |
|
@MelvinBot Deep review |
Deep review: no blocking issuesEvery moved helper is byte-identical to its original, every caller now uses the new location, and Non-blocking nits
What I verifiedMoved code is identical. I diffed each moved body against base
No stale references.
Onboarding parity.
Exports.
Checks run.
Not checked.
|
|
This request duplicates the earlier |
…ure-helper-leaves-v1 Conflicts in src/libs/actions/Welcome/OnboardingFlow.ts: this branch extracted the onboarding message builder into the leaf module buildOnboardingMessages.ts to break the import cycle, while main extended the inline builder with join-workspace tasks and messages. Kept the extraction and ported main's additions (addWorkEmail/validateEmail/ joinWorkspace tasks, join-workspace messages, extra OnboardingTaskLinks fields) into the leaf module, keeping the builder body byte-identical to main's. ReportUtils picked up main's getValidateEmailTaskDescription(), which called getOnboardingMessages() and would re-introduce the cycle; switched it to the leaf buildOnboardingMessages(onboarding) using ReportUtils' existing onboarding connection.
…ure-helper-leaves-v1 Conflict in src/libs/PolicyUtils/index.ts: this branch moved isCollectPolicy into the leaf isCollectPolicy.ts, while main moved the role permission bundles and isControlPolicyOnlyRole into the leaf permissions.ts. Both extractions are kept, so the import block is the union of the two and index.ts keeps re-exporting both leaves.
…ure-helper-leaves-v1
…ure-helper-leaves-v1 Conflicts in src/libs/PolicyUtils/index.ts: main extracted the policy-type helpers (isCollectPolicy, isControlPolicy, isPaidGroupPolicy, canPolicyAccessFeature, archived/pending delete and Submit/Group helpers) into a new leaf policyType.ts, which supersedes this branch's narrower isCollectPolicy.ts leaf and the local canPolicyAccessFeature definition. Took main's side in both hunks, deleted our now-redundant isCollectPolicy.ts, and repointed the only cycle-breaking importer (libs/actions/connections/index.ts) at PolicyUtils/policyType, which is also a leaf (CONST and types only) so the cycle stays broken. Also applied main's new patch-package patch for react-native-live-markdown via bun scripts/applyPatches.ts and cleared stale *.tsbuildinfo so typecheck sees the patched declarations.
…ure-helper-leaves-v1 Conflicts in src/libs/actions/Welcome/OnboardingFlow.ts and src/libs/ReportUtils.ts. Main reverted the join-workspace onboarding feature that a previous merge had brought in: the addWorkEmail/validateEmail/joinWorkspace tasks, joinWorkspaceMessages, the ONBOARDING_TASK_TYPE and ONBOARDING_CHOICES entries, and ReportUtils.getValidateEmailTaskDescription. Kept this branch's extraction of the message builder into the leaf buildOnboardingMessages.ts and reverted that leaf to main's builder body (now byte-identical), and dropped the now unreferenced getValidateEmailTaskLink/getValidateEmailTaskDescription helpers from ReportUtils.
…ure-helper-leaves-v1 # Conflicts: # src/pages/workspace/accounting/PolicyAccountingPage.tsx
…ure-helper-leaves-v1
…ure-helper-leaves-v1 Conflicts in src/libs/actions/Welcome/OnboardingFlow.ts and src/libs/PolicyUtils/index.ts. Main re-landed the join-workspace onboarding feature after a previous merge had seen it reverted, and extracted more PolicyUtils helpers into leaves (customUnits.ts, tax.ts, connections.ts, xero.ts, sageIntacct.ts). Kept this branch's extraction of the message builder into the leaf buildOnboardingMessages.ts and ported main's re-landed join-workspace additions (addWorkEmail/validateEmail/joinWorkspace tasks, join-workspace messages, extra OnboardingTaskLinks fields) into the leaf, keeping the builder body byte-identical to main's. In PolicyUtils took main's leaf extractions and restored shouldShowQBOReimbursableExportDestinationAccountError as a local definition: main moved it to actions/connections/QuickbooksOnline, whose new isPolicyAdmin import from PolicyUtils would reintroduce the index<->QuickbooksOnline cycle this branch exists to break.
…ure-helper-leaves-v1 Conflicts in src/libs/PolicyUtils/index.ts and PolicyCommuterExclusionsPage.tsx. Main kept splitting PolicyUtils into leaves (rules.ts, features.ts, workflows.ts, errors.ts) and moved shouldShowQBOReimbursableExportDestinationAccountError into actions/connections/QuickbooksOnline, whose isPolicyAdmin import from PolicyUtils would reintroduce the cycle this branch breaks. Kept the helper cycle-safe: defined in the PolicyUtils/errors.ts leaf next to its only user (getPolicyBrickRoadIndicatorStatus) and re-exported via the barrel, so all @libs/PolicyUtils callers and the existing test mock keep working without any QuickbooksOnline edge. CommuterExclusionsPage took a union: main's new hasCompanyAddress from PolicyUtils plus our getUnitTranslationKey import from the WorkspaceDisplayUtils leaf (main re-inlined it into WorkspacesSettingsUtils, which imports the PolicyUtils barrel; the leaf bodies are identical). Repointed main's new WorkspaceOfficeLocationForm at the same leaf for getWorkspaceAddressStreetLines. Refreshed node_modules via npm ci for main's victory-native 42 / repack 5.4 bumps, reapplied patches, and cleared tsbuildinfo caches.
…ure-helper-leaves-v1
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2026-10-18.at.18.03.34.mov |
thelullabyy
left a comment
There was a problem hiding this comment.
Thanks! I checked the moves hunk by hunk: every helper body is moved verbatim, every caller is updated, and buildOnboardingMessagesWithoutManageTeam() gives the same output for the validate-email, Personal spend and Submit messages that ReportUtils uses. CI is green. I only left two minor inline comments.
One optional follow-up: DistanceRequestUtils, SearchUIUtils and OnboardingFlow.getOnboardingMessages still re-export the moved helpers. That's fine for this PR, but moving the remaining callers to the new leaves later and dropping those re-exports would stop new code from importing through the heavy modules again.
| onboardingMessages: Omit<OnboardingMessages['onboardingMessages'], typeof CONST.ONBOARDING_CHOICES.MANAGE_TEAM>; | ||
| }; | ||
|
|
||
| function buildOnboardingMessagesWithoutManageTeam(locale?: Locale): OnboardingMessagesWithoutManageTeam { |
There was a problem hiding this comment.
The Manage team key is hidden only at the type level. At runtime this still builds the full object with onboardingData = undefined, so onboardingManageTeamMessage is created with isOnboardingFlow computed from undefined. That's fine today, because only Manage team reads onboardingData. But if anyone later makes another message depend on onboardingData, ReportUtils would quietly diverge from getOnboardingMessages() and nothing would flag it.
Could you add a short JSDoc here explaining why this variant exists (it avoids the module-level Onyx read and the cycle) and that it is only valid for messages that don't depend on onboardingData? The reason isn't obvious from the name alone.
There was a problem hiding this comment.
Right. Added in 3007ebc92fe. The JSDoc names both reasons, the import cycle and the module-level Onyx read, and says the variant is only valid for messages that don’t use onboarding data
| @@ -0,0 +1,327 @@ | |||
| import {translate} from '@libs/Localize'; | |||
There was a problem hiding this comment.
NAB: this is now a pure builder, so libs/actions/Welcome/ is a slightly odd home for it. Also, unlike the other new leaves, it imports Localize, IntlStore and a selector, not only CONST, types and Onyx, so the description's "leaf modules" claim doesn't quite cover it. The no-cycle count shows it's fine today. Maybe just update the description, or consider moving it under libs/ in a later part.
There was a problem hiding this comment.
True, I moved it to src/libs/buildOnboardingMessages. Only the path and imports changed. Description updated too
thelullabyy
left a comment
There was a problem hiding this comment.
Approved with non-blocking comments
Mirrors the committed .claude config for Codex-based agents: skill copies under .agents/skills and .codex config (MCP servers, hooks, agents).
This reverts commit 05440ee.
|
Comments addressed. Thank you for review |
…ure-helper-leaves-v1
…-pure-helper-leaves-v1 Conflicts: src/libs/actions/Search.ts Our branch drops the @libs/SearchUIUtils import to break the cycle; main adds getExpenseReportIDs and TODO_SEARCH_KEYS to it. Keep the type guard from the @libs/isTransactionGroupListItemType leaf and take only the new symbols from SearchUIUtils.
…nk it Our import/no-cycle work removed route param entries that main later deleted too, leaving the file at exactly 4000 lines. The max-lines rule errs at 4001+, so the file-top disable became an unused directive and lint fails on it.
|
🚧 roryabraham has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 9.5.15-1 🚀
|
|
No help site update is needed. This PR is a refactor that moves helpers into new modules and updates imports, with no user-facing behavior change. |
|
🚀 Deployed to production by https://github.com/grgia in version: 9.5.15-3 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
import/no-cyclecleanup. Seven pure helpers move out of heavy, cyclic modules into new modules. No helper body changes.CONST, types, and Onyx:DistanceUnitConversionUtils(meters to km/mi and back),WorkspaceDisplayUtils(unit translation key, address street lines),isTransactionGroupListItemType, andactions/getMakeDefaultPaymentOnyxData.buildOnboardingMessages(moved out ofOnboardingFlowintosrc/libs/) is not a strict leaf: it also importsLocalize,IntlStore, andselectors/Onboarding. None of them are part of a cycle with it.shouldShowQBOReimbursableExportDestinationAccountErrormoves fromactions/connections/QuickbooksOnlineintoPolicyUtils, which removes thePolicyUtilsto QBO actions edge.DistanceRequestUtils,SearchUIUtils,OnboardingFlow.getOnboardingMessages, andPolicyUtils(viaexport *) keep re-exporting the moved helpers.WorkspacesSettingsUtils(getUnitTranslationKey,getWorkspaceAddressStreetLines),QuickbooksOnline(shouldShowQBOReimbursableExportDestinationAccountError), andPaymentMethods(getMakeDefaultPaymentOnyxData) drop those exports, and every caller now imports from the new location.ReportUtils(getValidateEmailTaskDescription,prepareOnboardingOnyxData) now callsbuildOnboardingMessagesWithoutManageTeam()instead ofOnboardingFlow.getOnboardingMessages(). Onboarding data only changes the Manage team message, so the helper builds without it and its return type omits that key, which makes a Manage team read a type error. Output for the validate email, Personal spend, and Submit messages is identical, and no module-level Onyx value is read.No behavior change: every hunk moves a helper verbatim or updates an import. One smoke test checks the app still boots and the screens that import the new modules still render.
no cycle drop from 169 -> 153 (16), measured with oxlint 1.88
import/no-cycleFixed Issues
$ #99650
PROPOSAL:
Tests
Test 1: Smoke
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
android.mov
Android: mWeb Chrome
android.web.mov
iOS: Native
ios.mov
iOS: mWeb Safari
ios.web.mov
MacOS: Chrome / Safari
web.mov