Skip to content
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

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

Open
3 of 8 tasks
IuliiaHerets opened this issue Nov 12, 2024 · 14 comments
Open
3 of 8 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering Reviewing Has a PR in review Weekly KSv2

Comments

@IuliiaHerets
Copy link

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] 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: #52102
Email or phone of affected tester (no customers): [email protected]
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:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6661800_1731356979898.20241112_042538.mp4

View all open jobs on GitHub

@IuliiaHerets IuliiaHerets added DeployBlockerCash This issue or pull request should block deployment Bug Something is broken. Auto assigns a BugZero manager. labels Nov 12, 2024
Copy link

melvin-bot bot commented Nov 12, 2024

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

Copy link

melvin-bot bot commented Nov 12, 2024

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 melvin-bot bot added the Daily KSv2 label Nov 12, 2024
Copy link

melvin-bot bot commented Nov 12, 2024

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

@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Nov 12, 2024
Copy link
Contributor

👋 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
Copy link
Contributor

NJ-2020 commented Nov 12, 2024

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: #52102
We will show the category menu if the policy category id exist in nonPersonalPolicyCategoryIds

const nonPersonalPolicyCategoryIds = Object.values(policies)
.filter((policy): policy is NonNullable<Policy> => !!(policy && policy.type !== CONST.POLICY.TYPE.PERSONAL))
.map((policy) => `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policy.id}`);
const nonPersonalPolicyCategoryCount = Object.keys(allPolicyCategories).filter((policyCategoryId) => nonPersonalPolicyCategoryIds.includes(policyCategoryId)).length;
const shouldDisplayCategoryFilter = nonPersonalPolicyCategoryCount !== 0 || !!singlePolicyCategories;

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
const nonPersonalPolicyCategoryCount = Object.keys(allPolicyCategories).filter((policyCategoryId) => nonPersonalPolicyCategoryIds.includes(policyCategoryId)).length;

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
const nonPersonalPolicyCategoryCount = Object.keys(allPolicyCategories).filter((policyCategoryId) => nonPersonalPolicyCategoryIds.includes(policyCategoryId)).length;

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
Copy link
Contributor

Since this is a bug from #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
Copy link
Contributor

Kicu commented Nov 12, 2024

will write a comment here a bit later

@Kicu
Copy link
Contributor

Kicu commented Nov 12, 2024

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
Copy link
Contributor

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

@luacmartins luacmartins added Daily KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Nov 12, 2024
@luacmartins luacmartins changed the title Search - Category field is still present after deleting all the categories [Search v2.5] - Category field is still present after deleting all the categories Nov 12, 2024
@MariaHCD MariaHCD removed their assignment Nov 13, 2024
@SzymczakJ
Copy link
Contributor

@Kicu asked me to take a look at it, I think that solution that @NJ-2020 proposed is good(also tested it) and we should let him open a PR with it 😄
WDYT @luacmartins

@luacmartins
Copy link
Contributor

That works for me

@Kicu
Copy link
Contributor

Kicu commented Nov 15, 2024

FYI keep in mind that @sumo-slonik is also working on other filters misbehaving here: #52462

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Nov 15, 2024
@NJ-2020
Copy link
Contributor

NJ-2020 commented Nov 15, 2024

PR ready

@sumo-slonik
Copy link

FYI keep in mind that @sumo-slonik is also working on other filters misbehaving here: #52462

all related bugs for :
CategoryFilter
TagFilter
CardFilter
have been solved by this PR which was linked by Mateusz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering Reviewing Has a PR in review Weekly KSv2
Projects
None yet
Development

No branches or pull requests

8 participants