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.48k stars 2.83k forks source link

Search - "No category" is no longer selected in Categories field after searching with filter #50989

Open IuliiaHerets opened 2 hours ago

IuliiaHerets commented 2 hours 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.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: https://github.com/Expensify/App/pull/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:

Screenshots/Videos

https://github.com/user-attachments/assets/f1e74311-f0b8-478f-a445-ccf771278d99

View all open jobs on GitHub

melvin-bot[bot] commented 2 hours ago

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

melvin-bot[bot] commented 2 hours ago

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

melvin-bot[bot] commented 2 hours ago

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.

github-actions[bot] commented 2 hours 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.
Kicu commented 1 hour ago

I believe this may be a bug after this PR: https://github.com/Expensify/App/pull/50122 @luacmartins can you take a look? I didn't know we support "No category" option.

techievivek commented 1 hour ago

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

daledah commented 1 hour ago

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:

https://github.com/Expensify/App/blob/987ff1b536f2144e5fd492c6d2d2aa621d68442f/src/pages/Search/AdvancedSearchFilters.tsx#L260

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

https://github.com/Expensify/App/blob/987ff1b536f2144e5fd492c6d2d2aa621d68442f/src/components/Search/SearchPageHeader.tsx#L329-L334

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

https://github.com/Expensify/App/blob/987ff1b536f2144e5fd492c6d2d2aa621d68442f/src/libs/SearchUtils.ts#L709-L716

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)