Repository navigation
Description
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 theWRITE_COMMANDSenum (near the otherUPDATE_NETSUITE_*entries). - Add its type mapping using the existing
ConnectPolicyToNetSuiteParamstype (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 useWRITE_COMMANDS.UPDATE_NETSUITE_TOKENS.
3. Update form submission — src/pages/workspace/accounting/netsuite/NetSuiteTokenInput/substeps/NetSuiteTokenInputForm.tsx
- Import
updateNetSuiteTokensfromNetSuiteCommands. - Import
isAuthenticationErrorfrom@libs/actions/connections. - Import
usePolicyfrom@hooks/usePolicy(theSubStepWithPolicytype only providespolicyID, 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, callupdateNetSuiteTokens; otherwise callconnectPolicyToNetSuiteas before.
How to verify
- Token update scenario: With a NetSuite connection that has configured settings, simulate an auth error (set
isAuthenticationError: trueon the connection'slastSyncin Onyx) → re-enter credentials → verify network request goes toUpdateNetSuiteTokens(notConnectPolicyToNetSuite). - 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: @truph01Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022025938927275723055
- Upwork Job ID: 2025938927275723055
- Last Price Increase: 2026-02-23
Activity
melvin-bot commentedon Feb 13, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @truph01 (
External)melvin-bot commentedon Feb 13, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
melvin-bot commentedon Feb 13, 2026
Triggered auto assignment to @trjExpensify (
NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO. Remember to draft any necessary HelpDot updates by following the instructions here.melvin-bot commentedon Feb 13, 2026
Triggered auto assignment to Design team member for new feature review - @dannymcclain (
NewFeature)yifangoh commentedon Feb 13, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When users need to update their NetSuite token credentials (due to auth errors, token rotation, etc.), the app calls
ConnectPolicyToNetSuitewhich triggersinitConnectionon the backend — wiping all existing configuration (subsidiary, export destinations, mappings, custom segments). There's no way to update credentials without losing the entire connection setup.What is the root cause of that problem?
In
src/pages/workspace/accounting/netsuite/NetSuiteTokenInput/substeps/NetSuiteTokenInputForm.tsx, theconnectPolicycallback always callsconnectPolicyToNetSuite()regardless of whether this is a fresh connection or a credential update for an existing connection. The backend now supportsUpdateNetSuiteTokenswhich preserves config, but the frontend doesn't use it yet.What changes do you think we should make in order to solve the problem?
1. Add write command —
src/libs/API/types.tsAdd
UPDATE_NETSUITE_TOKENSto theWRITE_COMMANDSenum near the otherUPDATE_NETSUITE_*entries (~line 377):And add the type mapping using the existing params type (~line 983):
2. Add action function —
src/libs/actions/connections/NetSuiteCommands.tsAdd and export
updateNetSuiteTokens, mirroringconnectPolicyToNetSuite(same optimistic data for sync progress) but usingWRITE_COMMANDS.UPDATE_NETSUITE_TOKENS:Export it alongside
connectPolicyToNetSuite.3. Update form submission —
NetSuiteTokenInputForm.tsxImport the new action and the auth error check:
Use
usePolicyto get the full policy object (sinceSubStepWithPolicyonly providespolicyID), then branch in theconnectPolicycallback:This way, fresh first-time connections continue using
ConnectPolicyToNetSuite, while credential updates on existing connections with auth errors useUpdateNetSuiteTokens— preserving all user configuration.48 remaining items
melvin-bot commentedon Mar 30, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)[-][$250] Allow updating NetSuite tokens without resetting connection configuration[/-][+][Due for payment 30th March, 2026] [$250] Allow updating NetSuite tokens without resetting connection configuration[/+]truph01 commentedon Mar 30, 2026
BugZero Checklist:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment:
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎
trjExpensify commentedon Mar 31, 2026
@truph01 can you write steps that any QA tester can follow. See the note when you had this step in the PR.
trjExpensify commentedon Mar 31, 2026
@imgyf paid. 👍
yifangoh commentedon Mar 31, 2026
@trjExpensify Thank you sir.
truph01 commentedon Apr 1, 2026
@trjExpensify I updated the test in checklist.
trjExpensify commentedon Apr 2, 2026
Thanks, go ahead and request now. Closing!
garrettmknight commentedon May 10, 2026
$125 approved for @truph01