-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Netsuite - App crashes when tapping on export settings after disconnecting with another device #56021
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@hoangzinh It looks we have git conflict here, please resolve it. Thanks! |
…-on-another-device
Done @ahmedGaber93 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nearly there! We need to update those policyID defaults to match the new style, but otherwise looking good.
import CONST from '@src/CONST'; | ||
import ROUTES from '@src/ROUTES'; | ||
|
||
function NetSuiteCollectionAccountSelectPage({policy}: WithPolicyConnectionsProps) { | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
|
||
const policyID = policy?.id ?? '-1'; | ||
const policyID = policy?.id ?? `${CONST.DEFAULT_NUMBER_ID}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@dangrous, can you help confirm if Lines 976 to 977 in a8daefb
Lines 1000 to 1001 in a8daefb
I would like to get confirmation to fix TS error here Lines 43 to 45 in a8daefb
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ?? ''
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it's @ahmedGaber93
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Line 51 in 6668710
Navigation.goBack(policyID && ROUTES.POLICY_ACCOUNTING_NETSUITE_EXPORT_EXPENSES.getRoute(policyID, params.expenseType)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I don't mind that. What do you think @ahmedGaber93
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
goBack
without 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
POLICY_ACCOUNTING_NETSUITE_SUBSIDIARY_SELECTOR: { route: 'settings/workspaces/:policyID/accounting/netsuite/subsidiary-selector', getRoute: (policyID: string | undefined) => { if (!policyID) { Log.warn('Invalid policyID is used to build the POLICY_ACCOUNTING_NETSUITE_SUBSIDIARY_SELECTOR route'); } return `settings/workspaces/${policyID}/accounting/netsuite/subsidiary-selector` as const; }, },
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with 2nd option @dangrous. Do you agree with 2nd option? @ahmedGaber93
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. I will try to update it today
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Feel free to give another review @ahmedGaber93 @dangrous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.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