Skip to content

[No QA] Move NetSuite helpers out of PolicyUtils to fix max-lines lint failure - #102589

Merged
mjasikowski merged 3 commits into
mainfrom
claude-splitNetSuiteUtilsFromPolicyUtils
Sep 30, 2026
Merged

mjasikowski merged 3 commits into
mainfrom
claude-splitNetSuiteUtilsFromPolicyUtils

Conversation

@MelvinBot

Copy link
Copy Markdown
Contributor

Explanation of Change

The ESLint job on main fails because src/libs/PolicyUtils.ts is 4,039 lines, which is over the 4,000-line max-lines limit. The file was already at 4,000 lines, and #101643 added 39 more.

This PR moves the 19 NetSuite helpers (account and vendor option builders, tax checks, import labels, and custom field helpers) out of PolicyUtils.ts into a new src/libs/NetSuiteUtils.ts. These helpers form a self-contained group. No other code in PolicyUtils.ts calls them, and every caller is a NetSuite accounting page. PolicyUtils.ts drops to 3,826 lines, which leaves room for future changes.

This is a pure move with no behavior change:

  • The function bodies are unchanged.
  • The 16 caller files now import from @libs/NetSuiteUtils.
  • The seatbelt baseline moves one existing no-unsafe-type-assertion entry from PolicyUtils.ts to NetSuiteUtils.ts. The total count is unchanged.

AI Tests (run locally by MelvinBot):

  • npm run lint on all changed files: passed
  • npm run typecheck: passed
  • npm run fmt (oxfmt): no changes
  • npm run spell-changed: passed
  • npm test for PolicyUtilsTest, the NetSuite page and UI tests, and selectors/PolicyTest (10 suites, 642 tests): passed
  • npm run react-compiler-compliance-check check-changed: could not run in this environment because the script failed to resolve the base ref (origin/). The TSX changes only touch import lines.

Fixed Issues

$ #102585
PROPOSAL:

Tests

// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review"
// Please describe what tests you performed that validates your changed worked.

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: The human co-author must fill out the QA tests you ran before marking this PR as "ready for review".
// Please describe what QA needs to do to validate your changes and what areas do they need to test for regressions.

  • 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 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
iOS: mWeb Safari
MacOS: Chrome / Safari

MelvinBot and others added 2 commits September 30, 2026 00:27
…max-lines

Co-authored-by: Marc Glasser <marcaaron@users.noreply.github.com>
…tilsFromPolicyUtils

Co-authored-by: Marc Glasser <marcaaron@users.noreply.github.com>
@MelvinBot

MelvinBot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Web test steps verification results: ⚠️ partial

Home, Inbox, and the workspace Accounting page all loaded on web, including the NetSuite connect panel that uses the moved helpers, with no crash screens and no failed requests. The web test tool can't read the browser console, so the documented "no JS console errors" step is backed only by indirect evidence.
Inbox loaded

Step Status
Home and Inbox load correctlyHome showed the "Getting started" tasks and Concierge widgets. Inbox showed the Concierge welcome chat and onboarding tasks with no errors.
Home loaded
Inbox loaded
✅
Workspace > More features > Accounting loads, and the NetSuite UI rendersEnabled Accounting, then opened the Accounting tab. QuickBooks Online, Intuit Enterprise Suite, QuickBooks Desktop, Xero, NetSuite, and Sage Intacct all rendered. Clicking Connect on NetSuite showed the expected upgrade panel for a Collect workspace, with no blank screen or crash. Going back to the list also rendered cleanly.
Workspace overview
Accounting connections list
NetSuite connect panel
✅
Verify that no errors appear in the JS consoleThe web test tool has no console-log command, so console output couldn't be captured directly. Indirect evidence: every screen rendered with no error-boundary ("Something went wrong") screen, which is how a broken import usually shows up. The session's network dump showed only status 200 responses, including the API calls and JS bundle chunks (for example, OpenPolicyMoreFeaturesPage, EnablePolicyConnections, and the WorkspaceNavigator chunk).
⚠️

view run · view recording

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The failing check is unrelated to this PR, so I didn't push a fix. Please rerun the failed test (job 3) job.

Analysis: test (job 3) fails only in tests/ui/IOURequestRedirectToStartPageTest.tsx. Both tests throw ReferenceError: Request is not defined. The page makes a real API call, and the test never mocks fetch. The call reaches Expo's fetch polyfill from src/libs/HttpUtils.ts:118, which needs a Request global that Jest doesn't provide.

Evidence:

  • This PR only moves NetSuite helpers out of PolicyUtils. The only new runtime imports in NetSuiteUtils.ts are CONST and NetSuiteCustomFieldForm input IDs. Neither changes networking or the IOU redirect page.
  • No recent main commits changed HttpUtils.ts or jest/setup.ts.
  • Check independent approval also fails. That check is expected at this stage.

If the failure repeats after a rerun, the test needs a fetch mock (for example, global.fetch = TestHelper.getGlobalFetchMock()). That fix belongs in a separate PR.

@MelvinBot

MelvinBot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Android test steps verification results: ✅ pass

On Android, turning on Accounting, opening the Accounting page, and tapping Connect on NetSuite all ran the NetSuite code this PR moves. There were no console errors, no red box, and no crash. NetSuite still asks you to upgrade to the Control plan, which is the same as before the refactor.
NetSuite Connect tap navigates cleanly to the Control-plan upgrade screen, no crash

Step Status
Verify that no errors appear in the JS consoleLogcat covered the Accounting page load and the NetSuite Connect tap. It showed only normal Onyx, network, navigation, and Glide lines. It had no Error, Exception, or TypeError lines and nothing about PolicyUtils or NetSuiteUtils. Both screens loaded with no red box and no crash.
Workspace Accounting page listing all connectors including NetSuite
NetSuite Connect tap navigates cleanly to the Control-plan upgrade screen, no crash
✅

view run · view recording

@melvin-bot

melvin-bot Bot commented Sep 30, 2026

Copy link
Copy Markdown

@Pujan92 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 the request for review from a team September 30, 2026 07:44
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-30T07:57:32.968940Z f923c66 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.

Comment thread src/libs/NetSuiteUtils.ts
@@ -0,0 +1,221 @@
import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleContextProvider';

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.

❌ CONSISTENCY-13 (docs)

This new module contains non-trivial logic (19 NetSuite helper functions across ~221 lines) but opens straight into imports and code with no header comment. A one-line header orients the next reader to the file's purpose instead of forcing them to infer it from the exports.

Add a short header description above the imports, for example:

/**
 * Helpers for building NetSuite connection option lists (accounts, vendors, items, tax) and for reading NetSuite import/custom-field configuration from a policy.
 */
import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleContextProvider';

Reviewed at: f923c66 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The failing test (job 3) check is a breakage on main, not this PR, so I didn't push a fix here. [No QA] Mock fetch in IOURequestRedirectToStartPageTest to stop 'Request is not defined' failures fixes it and is still open. After it merges, merge main into this branch and the check should pass.

Evidence
  • The rerun failed the same way: only tests/ui/IOURequestRedirectToStartPageTest.tsx fails, with ReferenceError: Request is not defined (2 failed, 3802 passed).
  • The same test fails on unrelated branches, for example seatbelt/c13-260901-r13.
  • The test doesn't mock fetch, so the page's API call reaches Expo's fetch polyfill, which needs a Request global that Jest doesn't provide.
  • This PR only moves NetSuite helpers out of PolicyUtils. It doesn't touch networking, Jest setup, or the IOU redirect page.
  • Check independent approval also fails. That check is expected at this stage.

@Pujan92

This comment has been minimized.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The failing Jest check is not caused by this PR. Two tests in tests/ui/IOURequestRedirectToStartPageTest.tsx fail with ReferenceError: Request is not defined, and the same failure hits many unrelated PRs today. [No QA] Mock fetch in IOURequestRedirectToStartPageTest to stop 'Request is not defined' failures (Expensify/App#102624) already has an open fix. Once it merges, merge main into this PR or re-run the job.

Evidence
  • Failure: test (job 3) has 2 failed and 3,802 passed. Both failures come from IOURequestRedirectToStartPage: "clears a stale scan draft when a quick-action deeplink starts a distance request" and "always clears the OPTIMISTIC_TRANSACTION_ID draft even when the selector returns an empty list".
  • Mechanism: The test makes a real network call. The call goes through src/libs/HttpUtils.ts:118 into Expo's fetch polyfill (node_modules/expo/src/winter/fetch/fetch.ts:25). That polyfill calls Request, which doesn't exist in the Jest environment. The test doesn't mock fetch.
  • Not related to this PR: This PR only changes NetSuite helpers, NetSuite accounting pages, and the seatbelt baseline. It doesn't touch the test, IOURequestRedirectToStartPage, or HttpUtils. The test file hasn't changed since July.
  • Affects other PRs: Unrelated branches fail on the same test with the same error, for example claude-fixInvalidValidateCodeConstant (run). Many other Jest runs on unrelated branches failed today as well.

view run

@Pujan92

Pujan92 commented Sep 30, 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 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

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

Straightforward changes, LGTM!

@melvin-bot
melvin-bot Bot requested a review from marcaaron September 30, 2026 08:04
@@ -1,5 +1,5 @@
import {isAuthenticationError} from '@libs/actions/connections';
import {canUseProvincialTaxNetSuite, canUseTaxNetSuite} from '@libs/PolicyUtils';
import {canUseProvincialTaxNetSuite, canUseTaxNetSuite} from '@libs/NetSuiteUtils';

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.

This NetSuite util file imports functions from other NetSuiteUtils will be a bit confusing, but can be considered in follow-up.

…tilsFromPolicyUtils

Co-authored-by: Marc Glasser <marcaaron@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team as a code owner September 30, 2026 08:12
@melvin-bot
melvin-bot Bot requested review from Pujan92 and removed request for a team September 30, 2026 08:12
@melvin-bot

melvin-bot Bot commented Sep 30, 2026

Copy link
Copy Markdown

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

@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I merged the latest main into this branch in 133c3a1, and the checks are green now. Jest and ESLint both pass. The only failing check left is Check independent approval, which is expected until the PR gets approved.

Details
  • The Jest failure had nothing to do with this PR. It came from the flaky ReferenceError: Request is not defined in tests/ui/IOURequestRedirectToStartPageTest.tsx. Rerunning at the old commit failed again, but the new Jest run passed with the merged main.
  • I made no code changes to the PR. Git auto-merged config/eslint/eslint.seatbelt.tsv, and it picked up only main's rename of DynamicReportDetailsPage.tsx to DynamicReportDetailsPage/index.tsx.
  • The test is still flaky on main. [No QA] Mock fetch in IOURequestRedirectToStartPageTest to stop 'Request is not defined' failures is the permanent fix and is still open.

@mjasikowski

Copy link
Copy Markdown
Contributor

I'm pushing this forward to unblock CI

@mjasikowski
mjasikowski merged commit 100800d into main Sep 30, 2026
42 of 43 checks passed
@mjasikowski
mjasikowski deleted the claude-splitNetSuiteUtilsFromPolicyUtils branch September 30, 2026 08:28
@github-actions

Copy link
Copy Markdown
Contributor

🚧 mjasikowski has triggered a test Expensify/App build. You can view the workflow run here.

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

@OSBotify

OSBotify commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mjasikowski in version: 9.5.0-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No help site update is needed. This PR only moves NetSuite helper functions from PolicyUtils.ts into a new NetSuiteUtils.ts file and changes no user-facing behavior.


view run

@OSBotify

OSBotify commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/Julesssss in version: 9.5.0-5 🚀

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

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants