Fix NetSuite export Invoice item showing first item when preference unset#89569
Open
trasnake87 wants to merge 1 commit intoExpensify:mainfrom
Open
Fix NetSuite export Invoice item showing first item when preference unset#89569trasnake87 wants to merge 1 commit intoExpensify:mainfrom
trasnake87 wants to merge 1 commit intoExpensify:mainfrom
Conversation
…unset When invoiceItemPreference is unset (or 'create'), only resolve selectedItem when the user has explicitly chosen 'select existing'. This prevents the findSelectedInvoiceItemWithDefaultSelect fallback-to-first-item behavior from causing the export settings UI to display the first NetSuite item (e.g. 'EST99999') instead of the intended 'Create one for me' label.
|
@mananjadhav 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] |
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Author
|
recheck |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
The Invoice Item field on the NetSuite export settings page was showing the first NetSuite item (e.g.
EST99999) instead of the default "Create one for me" label when the user had never explicitly set an invoice item preference.findSelectedInvoiceItemWithDefaultSelectalways falls back toinvoiceItems?.[0]when no matching item is found, soselectedItemwas always truthy when items existed. The display switch on lines 78–85 then hit theelse if (selectedItem)branch and rendered the first item's name instead of the default label.The fix gates the call so
selectedItemis only resolved wheninvoiceItemPreference === 'select'. When the preference is unset or'create',selectedItemisundefinedand the existing display switch correctly resolves to "Create one for me". The fallback-to-first-item behavior offindSelectedInvoiceItemWithDefaultSelectis preserved (still useful for the "select existing" mode) but no longer triggers in modes where it produces a misleading default.Display logic was traced through all four
invoiceItemPreferencestates to confirm correctness:invoiceItemPreferenceselectedItemafter fixundefined(unset)undefined'create'undefined'select'+ item picked'select'+ no item pickedFixed Issues
$ #86489
PROPOSAL: #86489 (comment)
Tests
policy.connections.netsuite.options.config.invoiceItemPreferenceisundefinedin Onyx).Offline tests
Same as Tests. The change is purely client-side display logic that reads from Onyx; offline behaviour is unchanged.
QA Steps
Same as Tests, performed on staging against a workspace whose NetSuite invoice item preference has not been set.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioninvoiceItemPreferencestates render correctlytoggleReportand notonIconClick) — N/A, no callback changessrc/languages/*files and using the translation method — N/A, no copy changesSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected) — display logic forinvoiceItemValue(lines 78–85) and theMenuItemWithTopDescriptionforinvoiceItemreviewed for all four preference states; no other consumers ofselectedItemexist in this fileCONST.NETSUITE_INVOICE_ITEM_PREFERENCE.SELECTStyleUtils.getBackgroundAndBorderStyle(theme.componentBG)) — N/Anpm run compress-svg) — N/A, no asset changesAvataris modified, I verified thatAvataris working as expected in all cases) — N/A, modifies a page-specific componentNetSuiteExportConfigurationPagehas no Storybook storyDesignlabel and/or tagged@Expensify/designso the design team can review the changes — N/A, no design surface change (label text was already correct in CREATE mode; fix simply makes the unset state behave like CREATE)ScrollViewcomponent to make it scrollable when more elements are added to the page — N/A, no new pageNetSuiteExportConfigurationPage's display switch was found via grepmainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps — N/A, no rebase yetScreenshots/Videos
The change is in
src/pages/workspace/accounting/netsuite/export/NetSuiteExportConfigurationPage.tsx— shared cross-platform TypeScript with no.ios.tsx/.android.tsxvariant. The screenshots below show the app launching with the fix branch on each runtime.(The screenshots do not reproduce the in-page NetSuite Export bug state because that requires NetSuite sandbox credentials I do not have. If a test workspace can be provided, I'm happy to attach in-page before/after captures, or the in-page behaviour can be verified on staging using the test steps above.)
Android: Native
Pixel 7 / Android 15 AVD —
npm run androidGradle build + APK install + launch on the fix branch:Android: mWeb Chrome
Same web bundle as MacOS Chrome (shared artifact).
iOS: Native
Cross-platform shared source —
NetSuiteExportConfigurationPage.tsxresolves identically on iOS via React Native (no.ios.tsxoverride exists for this file). iOS Simulator screenshot can be attached on request.iOS: mWeb Safari
Same web bundle as MacOS Chrome (shared artifact).
MacOS: Chrome / Safari
Local dev server at
https://dev.new.expensify.com:8082/with the fix branch checked out. Webpack:webpack 5.105.0 compiled successfully in 181850 ms.