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.1] Web - Search filters - Search result becomes empty after changing sorting order #48483

Closed
2 of 6 tasks
lanitochka17 opened this issue Sep 3, 2024 · 9 comments
Closed
2 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Reviewing Has a PR in review Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Sep 3, 2024

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.28-0
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): [email protected]
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat
  3. Submit an expense with a category
  4. Go to Search
  5. Click Filters
  6. Click Category
  7. Select the category used in Step 3
  8. Also select another category that has not been used in any transaction
  9. Click Save
  10. Click View results
  11. Click on the sorting (Merchant, To, From etc)

Expected Result:

App will display the valid results

Actual Result:

Search result becomes empty after changing sorting order
This issue happens when two categories are selected in filters and one of the categories does not return results

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6591732_1725370201410.20240903_212347.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @289Adam289
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 3, 2024
Copy link

melvin-bot bot commented Sep 3, 2024

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

@daledah
Copy link
Contributor

daledah commented Sep 3, 2024

Proposal

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

Search result becomes empty after changing sorting order
This issue happens when two categories are selected in filters and one of the categories does not return results

What is the root cause of that problem?

Currently, when the user changes the sorting order, the buildSearchQueryString function is called, but in that function, it only returns a regular string here.
For example, with the filter Category set to Advertising and Car, it will return category:Advertising Benefits.

App/src/libs/SearchUtils.ts

Lines 350 to 353 in 7cb6bd3

if (queryFilter) {
const filterValueString = buildFilterString(filterKey, queryFilter);
queryParts.push(filterValueString);
}

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

We should separate the cases of filterKey as we did with the buildQueryStringFromFilters function here.

function buildQueryStringFromFilters(filterValues: Partial<SearchAdvancedFiltersForm>) {

What alternative solutions did you explore? (Optional)

@FitseTLT
Copy link
Contributor

FitseTLT commented Sep 3, 2024

Proposal

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

Web - Search filters - Search result becomes empty after changing sorting order

What is the root cause of that problem?

In building the search filter string here

filterValueString += ` ${sanitizeString(queryFilter.value.toString())}`;

we are concatenating the filter values with space which means AND so it will be searching for expenses which has two categories at the same time which will return empty

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

We should change it to , instead

            filterValueString += `,${sanitizeString(queryFilter.value.toString())}`;

What alternative solutions did you explore? (Optional)

@abzokhattab
Copy link
Contributor

abzokhattab commented Sep 3, 2024

Edited by proposal-police: This proposal was edited at 2024-09-03 16:28:37 UTC.

Proposal

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

  • Web - Search filters: Search result becomes empty after changing the sorting order.

What is the root cause of that problem?

  • When rebuilding the query, the separator is set as an empty space instead of a comma. This was introduced in this PR to show the Keyword filter value separated by a space.

  • Changing the separator back to a comma would reintroduce a regression and cause this bug .

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

  • We should check if the filter is Keyword, and if so, add a space separator; otherwise, add a comma.

  • This logic can be extended to handle other filters if needed.

const separator = filterName === FILTER_KEYS.KEYWORD ? " " : ",";
filterValueString += `${separator}${sanitizeString(queryFilter.value.toString())}`;

Result:

Screen.Recording.2024-09-03.at.18.26.17.mov

@289Adam289
Copy link
Contributor

Hi! I am from SWM, an expert agency and I'd like to work on this issue. I am working right now on Search Header Page cleanup and i can fix this bug in the same pr.

@trjExpensify
Copy link
Contributor

Go ahead and link it! CC: @luacmartins

@trjExpensify trjExpensify moved this to Release 2: Summer 2024 (Aug) in [#whatsnext] #expense Sep 4, 2024
@trjExpensify trjExpensify changed the title Web - Search filters - Search result becomes empty after changing sorting order [Search v2.1] Web - Search filters - Search result becomes empty after changing sorting order Sep 4, 2024
@luacmartins luacmartins self-assigned this Sep 4, 2024
@luacmartins
Copy link
Contributor

Linked here #48538

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 6, 2024
@trjExpensify
Copy link
Contributor

PR in active review, Melv.

@luacmartins
Copy link
Contributor

PR was deployed to prod last week. This is solved, closing.

@github-project-automation github-project-automation bot moved this from Polish to Done in [#whatsnext] #expense Sep 19, 2024
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. Reviewing Has a PR in review Weekly KSv2
Projects
Status: Done
Development

No branches or pull requests

7 participants