Repository navigation
[Refactor] Move PolicyUtils rules, feature, workflow, and error helpers into rules.ts, features.ts, workflows.ts, and errors.ts - #103958
Conversation
…es.ts, features.ts, workflows.ts, and errors.ts Co-authored-by: nkdengineer <nkdengineer@users.noreply.github.com>
Co-authored-by: nkdengineer <nkdengineer@users.noreply.github.com>
Co-authored-by: nkdengineer <nkdengineer@users.noreply.github.com>
|
I created this PR from an upstream branch since I don't have push access to your fork. To take ownership of this branch and be able to push updates, run: Then you can close this PR and open a new one from your fork. |
|
The failing
Evidence
|
|
🤖 Web test steps verification results: ✅ pass On dev NewDot web, the moved PolicyUtils workspace-rules/workflows/feature-toggle code works end-to-end: workspace creation and settings, More features toggles, Workflows (Submissions/Approvals), and Rules all render and operate without errors. Inbox and workspace navigation show no stray red error dots.
|
|
@MelvinBot Please add unit test for |
…and pending helpers Wrap the tests for helpers moved into rules.ts, features.ts, workflows.ts, and errors.ts in matching describe blocks, and add tests for areSettingsInErrorFields and settingsPendingAction. Co-authored-by: nkdengineer <nkdengineer@users.noreply.github.com>
|
Done in 7f23a3b. The tests for the moved helpers in
Some of these tests sat outside the main Checks
|
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.
|
|
@MelvinBot, fill out the Test section
Prerequisite: a Control workspace where you're the admin.
Prerequisite: a workspace connected to QuickBooks Online or Xero.
Then update |
|
Updated the PR description:
In the More features group, your list skipped step 5, so I renumbered the last three steps to 5–7. |
|
@MelvinBot, fill the Screenshots/VideosAndroid: NativeScreen.Recording.2026-10-14.at.15.57.35.movAndroid: mWeb ChromeScreen.Recording.2026-10-14.at.14.47.13.moviOS: NativeScreen.Recording.2026-10-14.at.14.48.03.moviOS: mWeb SafariScreen.Recording.2026-10-14.at.14.50.08.movMacOS: Chrome / SafariScreen.Recording.2026-10-14.at.14.41.53.movScreen.Recording.2026-10-14.at.14.43.55.movScreen.Recording.2026-10-14.at.14.45.12.mov |
|
I filled in the |
|
@MelvinBot, Update the Author Checklist section. Also, I verified there's no console error; then let's check for PR Author Checklist
|
|
@nkdengineer 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] |
|
Done. I updated the PR description and marked the PR ready for review.
I didn't change any other section. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2026-10-14.at.15.57.35.movAndroid: mWeb ChromeScreen.Recording.2026-10-14.at.14.47.13.moviOS: HybridAppScreen.Recording.2026-10-14.at.14.48.03.moviOS: mWeb SafariScreen.Recording.2026-10-14.at.14.50.08.movMacOS: Chrome / SafariScreen.Recording.2026-10-14.at.14.41.53.movScreen.Recording.2026-10-14.at.14.43.55.movScreen.Recording.2026-10-14.at.14.45.12.mov |
|
merge conflicts 😢 |
|
@MelvinBot Resolve conflicts. |
…lsRulesFeaturesWorkflowsErrors Co-authored-by: nkdengineer <nkdengineer@users.noreply.github.com> # Conflicts: # src/libs/PolicyUtils/index.ts # tests/unit/PolicyUtilsTest.ts
|
@nkdengineer 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] |
|
I merged
Details
|
|
MelvinBot has made 5 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR. Next steps: A human should review the recent commits and resolve the conflicting CI errors manually. |
|
@blimpich Done |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 blimpich has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/blimpich in version: 9.5.10-0 🚀
|
|
No help site update needed: this PR only moves |
|
🚀 Deployed to staging by https://github.com/blimpich in version: 9.5.12-0 🚀
|
|
No help site update needed. This PR only moves |
|
🚀 Deployed to production by https://github.com/cristipaval in version: 9.5.12-1 🚀
Bundle Size Analysis (Sentry): |


















Explanation of Change
Phase 6 of the
PolicyUtilssplit. It keepsPolicyUtils/index.tswell under the 4000-line ESLint limit, so the file stops breaking the build.index.tsdrops from 1992 to 1568 lines.This is a pure move. Nothing is renamed, no signature changes, and behavior is the same. Callers stay on
@libs/PolicyUtils.rules.ts(leaf): custom categories, max expense amounts,hasConfiguredRules,getTagApproverRule, and the rules document URL.features.ts:isPolicyFeatureEnabledand the checks it calls, plusgetDefaultTimeTrackingRate. It imports from./policyTypeand./connections.workflows.ts(leaf): instant and delayed submit, the corrected auto-reporting frequency, Submit & Close, and Dynamic External Workflow.errors.ts: policy error flags, the brick-road status, the two selector wrappers, and the settings error and pending helpers. It imports from./permissionsand./connections.shouldShowPolicyErrorFieldsstays private.index.tsre-exports all four withexport *, like the earlier phases. It importsgetTagApproverRule,isTimeTrackingEnabled, andisSubmitAndClosefor its own remaining callers.no-unsafe-type-assertioncasts moved with their functions, one toerrors.ts(shouldShowSyncError) and one torules.ts(hasConfiguredRules). Theindex.tsrow goes from 2 to 0 and is removed.jest.requireActual('@libs/PolicyUtils')whilePolicyUtilsis still loading inside an import cycle. At that point theexport *helpers aren't on the module yet, soisInstantSubmitEnabled,isSubmitAndClose, andhasDynamicExternalWorkflowcame through asundefined. Those mocks inSplitReportTotalsTestandReportSecondaryActionUtilsTestnow also spread@libs/PolicyUtils/workflows, the same fix used in earlier phases. App code is not affected, because imports read the barrel's live bindings at call time.AI tests run locally
npm run lint-changed: passednpm run typecheck: passednpm run fmt(oxfmt): no changesnpm run spell-changed: passed@libs/PolicyUtilsin a mock passed. So didPolicyUtilsTest,GettingStartedSectionTest,SearchUIUtilsTest,PolicyTest,TransactionUtilsTest,ViolationUtilsTest,OptionsListUtilsTest,ReportActionsUtilsTest, andTimeExpenseConfirmationTest. The fullnpm testrun doesn't finish within the local time limit, so CI is the full-suite signal.Fixed Issues
$ #102675
PROPOSAL: #102675 (comment)
Tests
Prerequisite: a Control workspace where you're the admin.
Prerequisite: a workspace connected to QuickBooks Online or Xero.
Offline tests
Same as test
QA Steps
Same as test
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, 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.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
Screen.Recording.2026-10-14.at.15.57.35.mov
Android: mWeb Chrome
Screen.Recording.2026-10-14.at.14.47.13.mov
iOS: Native
Screen.Recording.2026-10-14.at.14.48.03.mov
iOS: mWeb Safari
Screen.Recording.2026-10-14.at.14.50.08.mov
MacOS: Chrome / Safari
Screen.Recording.2026-10-14.at.14.41.53.mov
Screen.Recording.2026-10-14.at.14.43.55.mov
Screen.Recording.2026-10-14.at.14.45.12.mov