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 - "No category" is no longer selected in Categories field after searching with filter #50989

Closed
3 of 8 tasks
IuliiaHerets opened this issue Oct 17, 2024 · 10 comments
Closed
3 of 8 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Oct 17, 2024

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.50-0
Reproducible in staging?: Y
Reproducible in production?: N/A - new feature, doesn't exist in prod
Issue was found when executing this PR: #50122
Email or phone of affected tester (no customers): applausetester+kh081006@applause.expensifail.com
Issue reported by: Applause Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to Search.
  3. Click Filters.
  4. Click Categories and select one category and save it.
  5. Click View results.
  6. Click Filters.
  7. Note that the selected category in Step 4 is displayed in Categories field.
  8. Repeat Step 1 to 7 by selecting "No category" in Step 4.
  9. Note that after searching with "No category" filter, the selected "No category" is not displayed in Categories field in Filters page.

Expected Result:

"No category" will be displayed as selected in Categories field after searching with that filter.

Actual Result:

"No category" is no longer selected in Categories field after searching with that filter.

The same with tags filters

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6637286_1729142903137.20241017_132403.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 Oct 17, 2024
Copy link

melvin-bot bot commented Oct 17, 2024

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

Copy link

melvin-bot bot commented Oct 17, 2024

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

Copy link

melvin-bot bot commented Oct 17, 2024

Triggered auto assignment to @johncschuster (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 Oct 17, 2024
@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Oct 17, 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.

@Kicu
Copy link
Contributor

Kicu commented Oct 17, 2024

I believe this may be a bug after this PR: #50122
@luacmartins can you take a look? I didn't know we support "No category" option.

@techievivek
Copy link
Contributor

I think we can demote this for now as the impact is low.

@techievivek techievivek added Daily KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Oct 17, 2024
@daledah
Copy link
Contributor

daledah commented Oct 17, 2024

Proposal

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

"No category" is no longer selected in Categories field after searching with that filter.

What is the root cause of that problem?

In AdvancedSearchFilters, we calculate what title to display using:

const [searchAdvancedFilters = {} as SearchAdvancedFiltersForm] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM);

This Onyx value is set when we open advanced search filters page:

const onPress = () => {
const filterFormValues = SearchUtils.buildFilterFormValuesFromQuery(queryJSON, policyCategories, policyTagsLists, currencyList, personalDetails, cardList, reports, taxRates);
SearchActions.updateAdvancedFilters(filterFormValues);
Navigation.navigate(ROUTES.SEARCH_ADVANCED_FILTERS);
};

In buildFilterFormValuesFromQuery, we only match Category by value, and none is not in category list, so this part:

App/src/libs/SearchUtils.ts

Lines 709 to 716 in 987ff1b

if (filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.CATEGORY) {
const categories = policyID
? Object.values(policyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`] ?? {}).map((category) => category.name)
: Object.values(policyCategories ?? {})
.map((xd) => Object.values(xd ?? {}).map((category) => category.name))
.flat();
filtersForm[filterKey] = filters[filterKey]?.map((category) => category.value.toString()).filter((name) => categories.includes(name));
}

will return an empty array.

This bug happens to Tag search filter as well, because of the same RCA as above.

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

Add a condition to include none category if the search query has one, after this line

if (filters[filterKey]?.map((category) => category.value.toString()).includes(CONST.SEARCH.EMPTY_VALUE)) {
                filtersForm[filterKey]?.push(CONST.SEARCH.EMPTY_VALUE);
            }

Do the same with Tags as well.

What alternative solutions did you explore? (Optional)

@289Adam289
Copy link
Contributor

Hi! I can handle this in #50883. Fix requires minimal effort and I don't think it's worth opening another pr.

@289Adam289 289Adam289 mentioned this issue Oct 17, 2024
50 tasks
@289Adam289
Copy link
Contributor

I didn't noticed but pr adding no category and no tags has been reverted in #51015 so no fix needed.

@luacmartins
Copy link
Contributor

Correct, the PR was reverted. Closing this issue.

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. Daily KSv2 Engineering
Projects
None yet
Development

No branches or pull requests

7 participants