Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.34k stars 2.77k forks source link

[$250] Netsuite - App crashes when submitting an expense after disconnecting from NetSuite #46508

Open lanitochka17 opened 1 month ago

lanitochka17 commented 1 month ago

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: 9.0.14-2 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Email or phone of affected tester (no customers): N/A Issue reported by: Applause - Internal Team

Action Performed:

. Log in with a new expensifail account

  1. Create a new workspace
  2. Go to more features > Enable Accounting
  3. Go to Accounting > Connect to NetSuite
  4. Upgrade the workspace to Control > Navigate back to Accounting > Finish the connection to NetSuite
  5. Go to Accounting > Click on the 3 dot menu next to NetSuite
  6. Click on "Disconnect" > Confirm the disconnection > Check that the integration is removed from the workspace
  7. Navigate back from workspace page and go to FAB 9 Click on FAB > Submit Expense > Manual > Enter an amount
  8. Select the control workspace you disconnected NetSuite from

Expected Result:

The expense is submitted to the workspace

Actual Result:

App crashes

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/user-attachments/assets/43e8344d-9d28-4f0e-bbe9-1130ed71a8e5

logs (2).txt

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01a7f4450015473810
  • Upwork Job ID: 1819341847955308171
  • Last Price Increase: 2024-08-02
  • Automatic offers:
    • ShridharGoel | Contributor | 103438151
Issue OwnerCurrent Issue Owner: @eVoloshchak
melvin-bot[bot] commented 1 month ago

Triggered auto assignment to @bfitzexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

ShridharGoel commented 1 month ago

Proposal

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

App crashes when submitting an expense after disconnecting from NetSuite

What is the root cause of that problem?

This issue might happen if policyTagList or any tags within policyTagList is undefined or null.

https://github.com/Expensify/App/blob/df69c80229acdc510064d2671e2fdde8095a93a7/src/libs/OptionsListUtils.ts#L1402-L1406

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

function hasEnabledTags(policyTagList: Array<PolicyTagList[keyof PolicyTagList]>) {
    if (!policyTagList) {
        return false;
    }

    const policyTagValueList = policyTagList
        .filter(tag => tag && tag.tags) // Ensure tag and tag.tags are defined
        .map(({tags}) => Object.values(tags))
        .flat();

    return hasEnabledOptions(policyTagValueList);
}

We can check if we need to add similar checks as other places also.

ShridharGoel commented 1 month ago

CC: @luacmartins since I think you might be handling QBO/Netsuite bugs.

luacmartins commented 1 month ago

I think that'd be @yuwenmemon

ShridharGoel commented 1 month ago

Any plans to make this external?

melvin-bot[bot] commented 1 month ago

Job added to Upwork: https://www.upwork.com/jobs/~01a7f4450015473810

melvin-bot[bot] commented 1 month ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @eVoloshchak (External)

bfitzexpensify commented 1 month ago

Setting this as external for the moment - @yuwenmemon is ooo until August 13th.

daledah commented 1 month ago

Proposal

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

Netsuite - App crashes when submitting an expense after disconnecting from NetSuite

What is the root cause of that problem?

In https://github.com/Expensify/App/blob/459759d55963091c708d7271c29e0f95f3add658/src/libs/PolicyUtils.ts#L272, we filter out empty tags by checking policyTagListValue !== null. However this is not enough, there could be empty tags that only has required field, this empty tag, when not omitted in https://github.com/Expensify/App/blob/459759d55963091c708d7271c29e0f95f3add658/src/libs/PolicyUtils.ts#L272, is returned in the tag list and will cause the crash here because it doesn't have important fields like the tags field.

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

We need to improve the empty tags filtering logic here https://github.com/Expensify/App/blob/459759d55963091c708d7271c29e0f95f3add658/src/libs/PolicyUtils.ts#L272 to filter out empty tags based on the name field as well, if it's a valid tag, it will always have name (we can see that name is a required field here)

.filter((policyTagListValue) => policyTagListValue?.name)

This will ensure the policyTagsList returned from getTagLists is always correct and not only will it fix this crash in hasEnabledTags but anywhere we use the policyTagLists from getTagLists will also behave correctly.

What alternative solutions did you explore? (Optional)

We can check by the existence of tags field. Regardless, the fix needs to be in getTagLists so policyTagLists is correct and consistent everywhere it's used

melvin-bot[bot] commented 1 month ago

@eVoloshchak, @bfitzexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

eVoloshchak commented 1 month ago

Both proposals are fairly similar (different implementation, but same root cause and effectively the same fix, just in different place), I think we can proceed with @ShridharGoel's proposal

πŸŽ€πŸ‘€πŸŽ€ C+ reviewed!

melvin-bot[bot] commented 1 month ago

Triggered auto assignment to @marcaaron, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

melvin-bot[bot] commented 1 month ago

πŸ“£ @ShridharGoel πŸŽ‰ An offer has been automatically sent to your Upwork account for the Contributor role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review πŸ§‘β€πŸ’» Keep in mind: Code of Conduct | Contributing πŸ“–

bfitzexpensify commented 1 month ago

@ShridharGoel when will you be able to raise a PR here?

ShridharGoel commented 1 month ago

https://github.com/Expensify/App/pull/47232 -> Marked as "InternalQA" since I don't have the credentials to Netsuite.

melvin-bot[bot] commented 2 weeks ago

This issue has not been updated in over 15 days. @eVoloshchak, @marcaaron, @ShridharGoel, @bfitzexpensify eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!