Fix Netsuite - App crashes when tapping on export settings after disconnecting with another device#56021
Conversation
|
@ahmedGaber93 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] |
Reviewer Checklist
Screenshots/VideosAndroid: Nativea.mp4Android: mWeb Chromeaw.mp4iOS: NativeI failed to build the iOS on my environment, but this fix not limited to iOS, so the above videos is enough iOS: mWeb Safariiw.mp4MacOS: Chrome / Safariw.mp4MacOS: Desktopd.mp4 |
|
@hoangzinh I think we need to fix those places also, because they can crash with the same root cause ( |
|
Because it's a util, so I guess it will be caught somewhere before 👀 |
|
@hoangzinh That is mostly correct, but I think it not 100% because it depends on where we use it in. |
@ahmedGaber93 sure. I updated in this commit fe7d499. But it's failing test of CalendarPickerTest. There is a report in Slack here https://expensify.slack.com/archives/C01GTK53T8Q/p1738397681223439 |
|
The failing test will fix here #56229 |
|
@hoangzinh test should work now, let's merge main. |
…-on-another-device
|
@ahmedGaber93 Done. All checklist are passed |
|
@hoangzinh It looks we have git conflict here, please resolve it. Thanks! |
…-on-another-device
|
Done @ahmedGaber93 |
dangrous
left a comment
There was a problem hiding this comment.
nearly there! We need to update those policyID defaults to match the new style, but otherwise looking good.
| const {translate} = useLocalize(); | ||
|
|
||
| const policyID = policy?.id ?? '-1'; | ||
| const policyID = policy?.id ?? `${CONST.DEFAULT_NUMBER_ID}`; |
There was a problem hiding this comment.
I believe we shouldn't default this value anymore - https://github.com/Expensify/App/blob/main/contributingGuides/STYLE.md#default-value-for-inexistent-ids - "To address both problems, string IDs should not have a default value."
src/pages/workspace/accounting/netsuite/advanced/NetSuiteApprovalAccountSelectPage.tsx
Outdated
Show resolved
Hide resolved
...ages/workspace/accounting/netsuite/advanced/NetSuiteExpenseReportApprovalLevelSelectPage.tsx
Outdated
Show resolved
Hide resolved
src/pages/workspace/accounting/netsuite/advanced/NetSuiteVendorBillApprovalLevelSelectPage.tsx
Outdated
Show resolved
Hide resolved
|
checking! It looks like |
|
hey @hoangzinh I'm still not 100% sure but I think we can move forward with assuming |
|
Perfect. Thank you @dangrous |
|
Hey @dangrous @ahmedGaber93 I fixed type-check for "Default value for inexistent IDs" in this commit. Reg. Feel free to review this PR again. I tried to test as much as I can Screen.Recording.2025-02-07.at.16.05.31.mov |
|
Would it make more sense to update the Let us know what you think when you take another look, too, @ahmedGaber93 |
| const currentPayableAccountID = config?.[currentSettingName]; | ||
| const currentPayableAccountID = config?.[currentSettingName] ?? CONST.NETSUITE_PAYABLE_ACCOUNT_DEFAULT_VALUE; | ||
| const netsuitePayableAccountOptions = useMemo<SelectorType[]>(() => getNetSuitePayableAccountOptions(policy ?? undefined, currentPayableAccountID), [currentPayableAccountID, policy]); | ||
|
|
||
| const initiallyFocusedOptionKey = useMemo(() => netsuitePayableAccountOptions?.find((mode) => mode.isSelected)?.keyForList, [netsuitePayableAccountOptions]); | ||
|
|
||
| const updatePayableAccount = useCallback( | ||
| ({value}: SelectorType) => { | ||
| if (currentPayableAccountID !== value) { | ||
| if (currentPayableAccountID !== value && policyID) { | ||
| if (isReimbursable) { | ||
| Connections.updateNetSuiteReimbursablePayableAccount(policyID, value, currentPayableAccountID ?? ''); | ||
| updateNetSuiteReimbursablePayableAccount(policyID, value, currentPayableAccountID); |
There was a problem hiding this comment.
I think we shouldn't worry about this change, and no bugs can come from it, because we just pass the ESLint here.
Default to ?? CONST.NETSUITE_PAYABLE_ACCOUNT_DEFAULT_VALUE is the same as with default to ?? ''.
| if (row.value !== config?.journalPostingPreference) { | ||
| Connections.updateNetSuiteJournalPostingPreference(policyID, row.value, config?.journalPostingPreference); | ||
| if (row.value !== config?.journalPostingPreference && policyID) { | ||
| updateNetSuiteJournalPostingPreference(policyID, row.value, config?.journalPostingPreference); |
There was a problem hiding this comment.
Like #56021 (comment), would returning early inside updateNetSuiteJournalPostingPreference cleaner than using && policyID? Also for all places we check for && policyID?
There was a problem hiding this comment.
In my opinion, either way is the same and fine for LOCs above.
@dangrous please correct me if I'm wrong but I'm interpreting what you mentioned #56021 (comment) here is this line
There was a problem hiding this comment.
I'm open - haha, I just don't like Navigation.goBack(policyID && ... so anything that removes as many of those policy && and && policy as possible is ideal. Up to you which you prefer!
There was a problem hiding this comment.
The reason why I don't prefer this, because eventually, getRoute will return something like settings/workspaces/undefined/accounting, which is an invalid route.
Therefore, in my opinion, in case policyID is undefined/null, we should not pass fallbackRoute into Navigation.goBack, something like:
if (!policyID) {
Navigation.goBack()
} else {
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_NETSUITE_EXPORT_EXPENSES.getRoute(policyID, params.expenseType));
}which Navigation.goBack(policyID && ... is equivalent. What do you guys think?
There was a problem hiding this comment.
Yeah I don't mind that. What do you think @ahmedGaber93
There was a problem hiding this comment.
sorry was OOO! So looking again through the codebase, I think we have two patterns that we can match:
- early return if no policyID, as @ahmedGaber93 suggests. Example here though I didn't find m/any that were purely just
goBackwithout an operation before hand. - Within the route itself, allow for the bad route (
.../undefined/...) but log an error. Example [here] (but there are a lot more) ().Lines 1811 to 1819 in ed25f23
I think I'd still prefer the latter, because it'll be more clear to us when something is going wrong, and that seems to be what we've done most of the time - even specifically with NetSuite.
There was a problem hiding this comment.
I'm fine with 2nd option @dangrous. Do you agree with 2nd option? @ahmedGaber93
There was a problem hiding this comment.
Yeah, I'm fine with both. And I agree that the 2nd option is more clear to us when something is going wrong.
There was a problem hiding this comment.
Cool. I will try to update it today
There was a problem hiding this comment.
Done. Feel free to give another review @ahmedGaber93 @dangrous
dangrous
left a comment
There was a problem hiding this comment.
Awesome! Thanks for your patience with this one - it looks great,
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/dangrous in version: 9.1.6-0 🚀
|
|
🚀 Deployed to staging by https://github.com/dangrous in version: 9.1.6-0 🚀
|
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 9.1.6-1 🚀
|

Explanation of Change
Fixed Issues
$ #55723
PROPOSAL: #55723 (comment)
Tests
Same as QA
Offline tests
N/A this can't be test when network is offline
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Prerequisite
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))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2025-01-30.at.18.52.07.android.mov
Android: mWeb Chrome
Screen.Recording.2025-01-30.at.18.53.33.android.chrome.mov
iOS: Native
Screen.Recording.2025-01-30.at.17.28.02.ios.mov
iOS: mWeb Safari
Screen.Recording.2025-01-30.at.17.30.54.ios.safari.mov
MacOS: Chrome / Safari
Screen.Recording.2025-01-30.at.08.49.43.web.-.test1.mov
MacOS: Desktop
Screen.Recording.2025-01-30.at.08.54.01.desktop.mov