Fix: NetSuite auth error persists after correcting tokens on unverified connection#85200
Fix: NetSuite auth error persists after correcting tokens on unverified connection#85200imgyf wants to merge 1 commit intoExpensify:mainfrom
Conversation
… errors When a first-time NetSuite connection fails with incorrect tokens, the connection is never fully initialized (unverified). On retry with correct tokens, we should use connectPolicyToNetSuite (full init) instead of updateNetSuiteTokens (which only works for already-initialized connections). Fixes Expensify#85196 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@puneetlath 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 Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@imgyf did someone ask you to raise this PR? cc @madmax330 |
|
@puneetlath no, but the issue was surfaced by the deploy blocker that's caused by my other PR so I thought I had to be the one who fix it. Should I close this PR? |
|
Ah I see. Ok if you were the one who raised the original PR that makes sense to me. |
|
@imgyf can you add as reviewer the C+ who reviewed the offending PR? cc @luacmartins since you're app deployer |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroidNetsuite.movAndroid: mWeb ChromeScreen.Recording.2026-03-14.at.2.00.53.AM.moviOS: HybridAppScreen.Recording.2026-03-14.at.2.07.25.AM.moviOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2026-03-14.at.1.35.49.AM.movScreen.Recording.2026-03-14.at.1.40.45.AM.mov |
|
Edit: Looks like this behaviour is same as prod, so we can ignore. After trying again (either with the correct details or not), the error text does not go away immediately. Ideally, it should be gone and only show again if there's some error again. Looks like the error is not being cleared optimistically. Screen.Recording.2026-03-14.at.1.40.45.AM.mov |
|
Looks like this behaviour is same as prod, so we can ignore. |
|
@imgyf Can you complete the checklist? Some points are not checked, and there are no videos/screenshots. |
|
Not having videos is fine though, since you'll not be having the Netsuite creds. |
|
Can you add tests in a follow-up ? |
|
In the test steps, it is mentioned:
But there's no way to update the tokens without disconnecting the connection. Can you remove these two steps? |
There was a problem hiding this comment.
Approving, with the expectation that manual testing steps in the description will be updated and unit tests will be added in a follow-up.
Explanation of Change
PR #83434 introduced a regression where first-time NetSuite connections that fail with incorrect tokens cannot be corrected. The issue is that
updateNetSuiteTokens(designed for already-initialized connections) was being called for unverified connections that had never successfully connected. The backendUpdateNetSuiteTokenscommand skipsinitConnection, so it fails for connections that were never fully initialized.This fix adds an
isConnectionUnverifiedcheck so that:updateNetSuiteTokens(preserves existing configuration)connectPolicyToNetSuite(runs full initialization)Fixed Issues
$ #85196
Tests
Offline tests
N/A - NetSuite connection requires network connectivity to authenticate with NetSuite servers. The form submission is queued via the standard Onyx optimistic update pattern which already handles offline gracefully.
QA Steps
Same as Tests (steps 1-9), performed on staging environment.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari