Skip to content

[Due for payment 2026-03-30] NetSuite - Not able to connect the integration with correct tokens, when edit incorrect input #85196

Closed

Description

@jponikarchuk

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.3.37-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-8760/folder/13176904/41237417/1247678955?sort=%2Bidentifier
Email or phone of affected tester (no customers): forexmater+332323423424@gmail.com
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Windows 10/Chrome
App Component: Workspace Settings

Action Performed:

Preconditions: Create fresh account; Create workspace;

  1. Go to https://staging.new.expensify.com/
  2. Enable "Accounting" on the created workspace
  3. Click "Connect" at NetSuite (upgrade the workspace)
  4. Enter incorrect the NetSuite tokens
  5. Click on the 3 dot menu next to the connection
  6. Enter the correct tokens > Confirm
  7. Disconnect the integration
  8. Click "Connect" at NetSuite
  9. Enter the correct tokens > Confirm

Expected Result:

Entering the Netsuite credentials incorrectly should trigger an error state and RBRs to indicate the connection error, but after edit the credentials should clear the error and connect Netsuite successful.

Actual Result:

Entering the Netsuite credentials incorrectly trigger an error state and RBRs, but after edit the credentials with correct tokens trigger the error "Can’t connect to NetSuite due to an authentication error. Learn more." again and the integration is not connected.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

bandicam.2026-03-13.09-13-31-790.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 13, 2026
  2. melvin-bot commented on Mar 13, 2026

    @melvin-bot

    Triggered auto assignment to @madmax330 (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  3. melvin-bot commented on Mar 13, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. github-actions commented on Mar 13, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  5. OSBotify commented on Mar 13, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #83434 - "Fix: Allow updating NetSuite tokens without resetting connection configuration" by @imgyf (High confidence)
    Related Issues: #82339

    Recommendation: ROLL FORWARD

    PR #83434 fixes an important issue (preventing configuration reset when updating tokens), but introduced this bug. The fix is simpler than reverting - add optimistic data to clear the authentication error flag when submitting new credentials.

    Labels: No changes needed. Keeping DeployBlockerCash as this is a frontend bug requiring an App PR fix.

    Detailed Analysis

    Evidence

    PR #83434 was merged on March 12, 2026 and is included in the v9.3.37-0 staging deploy. It adds a new updateNetSuiteTokens command to allow users to update NetSuite credentials without resetting their entire connection configuration.

    The bug reproduction steps match exactly with the new code path introduced by this PR:

    1. Enter incorrect NetSuite tokens → backend sets isAuthenticationError: true on the connection
    2. Click 3-dot menu > Enter credentials
    3. The form detects isAuthenticationError(policy) and calls updateNetSuiteTokens instead of connectPolicyToNetSuite
    4. User enters correct credentials and submits
    5. Error persists because the isAuthenticationError flag is not optimistically cleared

    Verification

    The bug is in /home/runner/_work/App/App/src/libs/actions/connections/NetSuiteCommands.ts:

    The writeNetSuiteCredentials function (lines 21-42) only sets optimistic data for POLICY_CONNECTION_SYNC_PROGRESS:

    const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS>> = [
        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`,
            value: {
                stageInProgress: CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.NETSUITE_SYNC_CONNECTION,
                connectionName: CONST.POLICY.CONNECTIONS.NAME.NETSUITE,
                timestamp: new Date().toISOString(),
            },
        },
    ];

    It does NOT clear the isAuthenticationError flag in the POLICY collection, which is checked by isAuthenticationError() function in /home/runner/_work/App/App/src/libs/actions/connections/index.ts line 264:

    function isAuthenticationError(policy: OnyxEntry<Policy>, connectionName: PolicyConnectionName) {
        const connection = policy?.connections?.[connectionName];
        return connection?.lastSync?.isAuthenticationError === true;
    }

    Root Cause

    When a user submits correct credentials after an authentication error, the frontend should optimistically clear the error state to provide immediate UI feedback. The backend will eventually update this when the sync completes successfully, but without optimistic updates, the error message persists on screen even though the user entered valid credentials.

    The fix needs to add optimistic data to clear connections.netsuite.lastSync.isAuthenticationError when updateNetSuiteTokens is called.

  6. MelvinBot commented on Mar 13, 2026

    @MelvinBot
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When a user connects NetSuite with incorrect tokens, an authentication error is shown (expected). However, after editing the credentials with correct tokens (via the 3-dot menu > Enter credentials) or disconnecting and reconnecting with correct tokens, the error "Can't connect to NetSuite due to an authentication error" persists and the integration cannot be connected.

    What is the root cause of that problem?

    PR Expensify/App#83434 (merged March 12, 2026) introduced a regression in NetSuiteTokenInputForm.tsx. It changed the form submission logic to call updateNetSuiteTokens() (which sends the UpdateNetSuiteTokens backend command) when isAuthenticationError is true, instead of always calling connectPolicyToNetSuite() (which sends ConnectPolicyToNetSuite).

    The UpdateNetSuiteTokens backend command is designed for existing, fully-initialized connections — it updates credentials and triggers a sync while preserving existing configuration. However, it skips initConnection on the backend.

    The problem: when a first-time connection fails with incorrect tokens, the backend sets lastSync.isAuthenticationError = true on the connection object. On the next attempt with correct tokens, isAuthenticationError() at src/libs/actions/connections/index.ts:262-264 returns true, so the form sends UpdateNetSuiteTokens instead of ConnectPolicyToNetSuite. Since the connection was never successfully initialized, the update command fails, and the user is stuck in an error loop.

    The critical code is at src/pages/workspace/accounting/netsuite/NetSuiteTokenInput/subPages/NetSuiteTokenInputForm.tsx:52-56:

    if (isAuthenticationError(policy, CONST.POLICY.CONNECTIONS.NAME.NETSUITE)) {
        updateNetSuiteTokens(policyID, formValues);
    } else {
        connectPolicyToNetSuite(policyID, formValues);
    }

    The isAuthenticationError check does not distinguish between a first-time connection that failed (needs initConnection via ConnectPolicyToNetSuite) and an existing verified connection that lost authentication (can use UpdateNetSuiteTokens).

    What changes do you think we should make in order to solve the problem?

    The fix should add a check for whether the connection was ever successfully initialized before choosing which API command to use. The isConnectionUnverified() function already exists at src/libs/actions/connections/index.ts:267-273 and checks the NetSuite-specific verified property.

    In NetSuiteTokenInputForm.tsx, update the conditional to:

    • If isAuthenticationError AND the connection is verified (previously working) → use updateNetSuiteTokens (preserves configuration)
    • If isAuthenticationError AND the connection is unverified (never successfully connected) → use connectPolicyToNetSuite (runs full initConnection)

    This preserves the original intent of PR #83434 (not resetting configuration for existing connections) while fixing the regression for first-time connection failures.

    What alternative solutions did you explore? (Optional)

    1. Revert PR Fix: Allow updating NetSuite tokens without resetting connection configuration #83434 entirely — This would fix the regression but would re-introduce the original issue ([Due for payment 30th March, 2026] [$250] Allow updating NetSuite tokens without resetting connection configuration #82339) where re-entering credentials on existing connections resets all configuration. Not recommended.

    2. Always use ConnectPolicyToNetSuite and handle config preservation on the backend — This would avoid the client-side branching but requires backend changes. More invasive than necessary.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  7. added a commit that references this issue on Mar 13, 2026
    261e18e
  8. ShridharGoel commented on Mar 13, 2026

    @ShridharGoel
    Contributor

    @madmax330 Can you assign me on this since I've reviewed? Thanks

  9. 28 remaining items

  10. melvin-bot commented on Mar 30, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  11. melvin-bot commented on Mar 30, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  12. mallenexpensify commented on Mar 31, 2026

    @mallenexpensify
    Contributor

    @ShridharGoel can you provide more details and links for

    @madmax330 Can you assign me on this since I've reviewed? Thanks

    and

    The commit message had Fixes #85196 because of which this got closed on merging.

    I'm working on updating our process to have the C+ who reviewed the likely offending PR (as listed in OSBotify's post) to be assigned to deploy blockers issues. Thx

  13. ShridharGoel commented on Mar 31, 2026

    @ShridharGoel
    Contributor

    @mallenexpensify I had reviewed this: #85200

    The commit message had Fixes #85196 because of which this got closed on merging

    This issue got auto-closed when the PR was merged because the commit had Fixes #85196 which signals GH that the linked issue should be closed once that commit/PR gets merged.

  14. mallenexpensify commented on Apr 1, 2026

    @mallenexpensify
    Contributor

    Thanks @ShridharGoel

    From here in your PR, do we want retest here to confirm the bug isn't still occurring?

    Also.. how much are you due here @ShridharGoel ? I think it's either $250 or $375.

  15. ShridharGoel commented on Apr 1, 2026

    @ShridharGoel
    Contributor

    Yes, can we ask for a retest?

    Also, any reason you're also considering $375 ?

  16. mallenexpensify commented on Apr 1, 2026

    @mallenexpensify
    Contributor

    Also, any reason you're also considering $375 ?

    It looked like there were two PRs to review and one didn't have tests performed (I think, I'd have to go back and find/view links to PRs here)

    Requesting retest

  17. m-natarajan commented on Apr 2, 2026

    @m-natarajan

    Not repro, Windows 11 / Chrome, v9.3.51-7

    netsuite.mp4
  18. mallenexpensify commented on Apr 2, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @ShridharGoel due $250 via NewDot

    comment and tag me if ya disagree. Thx

  19. ShridharGoel commented on Apr 2, 2026

    @ShridharGoel
    Contributor

    It looked like there were two PRs to review and one didn't have tests performed (I think, I'd have to go back and find/view links to PRs here)

    Yeah, the second one was to add unit tests

  20. JmillsExpensify commented on Apr 6, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @ShridharGoel

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2Engineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions