Problem
When a user needs to update their NetSuite token credentials — whether due to an authentication error, token rotation, or any other reason — the App calls ConnectPolicyToNetSuite, which triggers an initConnection job on the backend. This resets all user configuration (subsidiary, export destinations, mappings, custom segments, etc.).
There is no way to update NetSuite credentials without wiping out the entire connection setup. Users are forced to reconfigure everything from scratch just to rotate tokens. This feature exists in OldDot:
Solution
The backend now supports a new API command UpdateNetSuiteTokens that validates and updates credentials, then triggers a sync — all while preserving existing config. The App needs to use this new command when the user already has an existing NetSuite connection and is updating their credentials.
The current UI surface for this is the token input form shown when a connection has isAuthenticationError === true. In that flow, the App should call UpdateNetSuiteTokens instead of ConnectPolicyToNetSuite. Fresh first-time connections should continue using ConnectPolicyToNetSuite.
Changes needed
1. Add write command — src/libs/API/types.ts
- Add
UPDATE_NETSUITE_TOKENS: 'UpdateNetSuiteTokens' to the WRITE_COMMANDS enum (near the other UPDATE_NETSUITE_* entries).
- Add its type mapping using the existing
ConnectPolicyToNetSuiteParams type (same parameters: policyID, netSuiteAccountID, netSuiteTokenID, netSuiteTokenSecret).
2. Add action function — src/libs/actions/connections/NetSuiteCommands.ts
- Add and export an
updateNetSuiteTokens(policyID, credentials) function.
- It should mirror
connectPolicyToNetSuite (same optimistic data for sync progress) but use WRITE_COMMANDS.UPDATE_NETSUITE_TOKENS.
3. Update form submission — src/pages/workspace/accounting/netsuite/NetSuiteTokenInput/substeps/NetSuiteTokenInputForm.tsx
- Import
updateNetSuiteTokens from NetSuiteCommands.
- Import
isAuthenticationError from @libs/actions/connections.
- Import
usePolicy from @hooks/usePolicy (the SubStepWithPolicy type only provides policyID, not the full policy object).
- Call
usePolicy(policyID) to get the policy.
- In the connectPolicy callback: if
isAuthenticationError(policy, CONST.POLICY.CONNECTIONS.NAME.NETSUITE) is true, call updateNetSuiteTokens; otherwise call connectPolicyToNetSuite as before.
How to verify
- Token update scenario: With a NetSuite connection that has configured settings, simulate an auth error (set
isAuthenticationError: true on the connection's lastSync in Onyx) → re-enter credentials → verify network request goes to UpdateNetSuiteTokens (not ConnectPolicyToNetSuite).
- Fresh connection scenario: Connect NetSuite for the first time → verify the request still goes to
ConnectPolicyToNetSuite.
- Run
npm run typecheck, npm run prettier, and lint on changed files.
Related to https://github.com/Expensify/Expensify/issues/598576
Issue Owner
Current Issue Owner: @truph01
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022025938927275723055
- Upwork Job ID: 2025938927275723055
- Last Price Increase: 2026-02-23
Problem
When a user needs to update their NetSuite token credentials — whether due to an authentication error, token rotation, or any other reason — the App calls
ConnectPolicyToNetSuite, which triggers aninitConnectionjob on the backend. This resets all user configuration (subsidiary, export destinations, mappings, custom segments, etc.).There is no way to update NetSuite credentials without wiping out the entire connection setup. Users are forced to reconfigure everything from scratch just to rotate tokens. This feature exists in OldDot:
Solution
The backend now supports a new API command
UpdateNetSuiteTokensthat validates and updates credentials, then triggers a sync — all while preserving existing config. The App needs to use this new command when the user already has an existing NetSuite connection and is updating their credentials.The current UI surface for this is the token input form shown when a connection has
isAuthenticationError === true. In that flow, the App should callUpdateNetSuiteTokensinstead ofConnectPolicyToNetSuite. Fresh first-time connections should continue usingConnectPolicyToNetSuite.Changes needed
1. Add write command —
src/libs/API/types.tsUPDATE_NETSUITE_TOKENS: 'UpdateNetSuiteTokens'to theWRITE_COMMANDSenum (near the otherUPDATE_NETSUITE_*entries).ConnectPolicyToNetSuiteParamstype (same parameters:policyID,netSuiteAccountID,netSuiteTokenID,netSuiteTokenSecret).2. Add action function —
src/libs/actions/connections/NetSuiteCommands.tsupdateNetSuiteTokens(policyID, credentials)function.connectPolicyToNetSuite(same optimistic data for sync progress) but useWRITE_COMMANDS.UPDATE_NETSUITE_TOKENS.3. Update form submission —
src/pages/workspace/accounting/netsuite/NetSuiteTokenInput/substeps/NetSuiteTokenInputForm.tsxupdateNetSuiteTokensfromNetSuiteCommands.isAuthenticationErrorfrom@libs/actions/connections.usePolicyfrom@hooks/usePolicy(theSubStepWithPolicytype only providespolicyID, not the full policy object).usePolicy(policyID)to get the policy.isAuthenticationError(policy, CONST.POLICY.CONNECTIONS.NAME.NETSUITE)is true, callupdateNetSuiteTokens; otherwise callconnectPolicyToNetSuiteas before.How to verify
isAuthenticationError: trueon the connection'slastSyncin Onyx) → re-enter credentials → verify network request goes toUpdateNetSuiteTokens(notConnectPolicyToNetSuite).ConnectPolicyToNetSuite.npm run typecheck,npm run prettier, and lint on changed files.Related to https://github.com/Expensify/Expensify/issues/598576
Issue Owner
Current Issue Owner: @truph01Upwork Automation - Do Not Edit