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.55k stars 2.89k forks source link

[Search v2.5] - Category field is still present after deleting all the categories #52362

Open IuliiaHerets opened 1 day ago

IuliiaHerets commented 1 day 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.60-0 Reproducible in staging?: Y Reproducible in production?: N If this was caught during regression testing, add the test name, ID and link from TestRail: https://github.com/Expensify/App/pull/52102 Email or phone of affected tester (no customers): applausetester+290324@applause.expensifail.com Issue reported by: Applause Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Log in with a new account.
  3. Create a new workspace.
  4. Go to workspace settings > More features.
  5. Enable Tags.
  6. Go to Tags and add some tags.
  7. Go to Search > Filters.
  8. Note that Category and Tag fields are present.
  9. Go back to workspace settings.
  10. Delete all categories and tags.
  11. Go to Search > Filters.

Expected Result:

Both Category and Tag fields will not be present because there are no categories and tags.

Actual Result:

Category field is still present after deleting all the categories, while Tag field is not present which is expected.

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/b502db54-f355-431c-be27-f9f7ef16a0df

View all open jobs on GitHub

melvin-bot[bot] commented 1 day ago

Triggered auto assignment to @MariaHCD (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

melvin-bot[bot] commented 1 day ago

Triggered auto assignment to @strepanier03 (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.

melvin-bot[bot] commented 1 day ago

💬 A slack conversation has been started in #expensify-open-source

github-actions[bot] commented 1 day ago

:wave: Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.
NJ-2020 commented 1 day ago

Edited by proposal-police: This proposal was edited at 2024-11-12 10:11:34 UTC.

Proposal

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

Search - Category field is still present after deleting all the categories

What is the root cause of that problem?

Offending PR: https://github.com/Expensify/App/pull/52102 We will show the category menu if the policy category id exist in nonPersonalPolicyCategoryIds https://github.com/Expensify/App/blob/e3632a9877542727230814ffc9fdd78bd087ecbd/src/pages/Search/AdvancedSearchFilters.tsx#L279-L284 When we create new workspace and enable the categories feature, the category menu item will show because the policy category id is exist inside nonPersonalPolicyCategoryIds https://github.com/Expensify/App/blob/e3632a9877542727230814ffc9fdd78bd087ecbd/src/pages/Search/AdvancedSearchFilters.tsx#L282 But when we delete all the categories, the policy category id still exists in this allPolicyCategories with empty object value and when when we check if the policy category is exist inside nonPersonalPolicyCategoryIds it will return true which cause this issue https://github.com/Expensify/App/blob/e3632a9877542727230814ffc9fdd78bd087ecbd/src/pages/Search/AdvancedSearchFilters.tsx#L282

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

Inside allPolicyCategories we should filter out if the value is empty object

const filteredPoliciyCategories = useMemo(() => Object.values(allPolicyCategories ?? {}).filter((policyCategory) => !isEmptyObject(policyCategory)), [allPolicyCategories])

OR

const nonPersonalPolicyCategoryCount = Object.keys(allPolicyCategories).filter(
    (policyCategoryId) => nonPersonalPolicyCategoryIds.includes(policyCategoryId) && !isEmptyObject(allPolicyCategories[policyCategoryId]),
).length;

const shouldDisplayCategoryFilter = nonPersonalPolicyCategoryCount !== 0 || !!singlePolicyCategories;

What alternative solutions did you explore? (Optional)

MariaHCD commented 1 day ago

Since this is a bug from https://github.com/Expensify/App/pull/52102 and we're still in the regression period, the original PR author will be handling the fix for this.

cc: @Kicu @fedirjh @luacmartins

Kicu commented 1 day ago

will write a comment here a bit later

Kicu commented 1 day ago

Please assign me, I will provide a fix for this. That being said I don't think this is necessarily a deploy blocker, maybe @luacmartins you can verify

luacmartins commented 1 day ago

Yea, this is not a blocker. Assigning it to you @Kicu