Skip to content

[Due for payment 30th March, 2026] [$250] Allow updating NetSuite tokens without resetting connection configuration #82339

Description

@yuwenmemon

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:

Image

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.

Image

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

  1. 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).
  2. Fresh connection scenario: Connect NetSuite for the first time → verify the request still goes to ConnectPolicyToNetSuite.
  3. Run npm run typecheck, npm run prettier, and lint on changed files.

Related to https://github.com/Expensify/Expensify/issues/598576

Issue OwnerCurrent 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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorNewFeatureSomething to build that is a new item.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions