Skip to content

[Due for payment 2026-02-27] [$250] Reports - Filters counter is displayed despite no filter being applied. #79857

Closed

Description

@jponikarchuk

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.3.4.0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-3005/folder/13176922/49980929/1130572023
Email or phone of affected tester (no customers): ibellicotest+2250@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Motorola MotoG60 / Android 12 / Chrome ( mWeb / Hybrid app) - Windows 11 / Chrome
App Component: Search

Action Performed:

  1. Open the Expensify app.
  2. Navigate to "Reports" > "Expenses"
  3. Note that no count is displayed on "Filters"
  4. Open the "Filters" tab.
  5. Open a filter that is not displayed in the main filters bar (For example: Has)
  6. Tap on "Category" and tap on "Save"
  7. When redirected to the general filters tab, tap on the arrow on the top left corner, without saving the search or without tapping on "View Results" before.
  8. Note that filter is not applied, as it wasn´t saved, but filters count is displayed with a (1).
  9. Reopen filters tab.
  10. Reopen "Has"
  11. Tap on "Reset" > "Save"
  12. Tap on the arrow on the top left corner.
  13. Note that filters counter is still displayed with a (1)
  14. Reopen filters tab one more time.
  15. Note that "Has" field is displayed empty, as filter is not applied.
  16. Note that "Reset Filters" option is not displayed, as no filter is applied.

Expected Result:

Filters counter shouldn´t be displayed when no filter was applied.

Actual Result:

Filters counter is displayed despite no filter being applied and saved.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022013888257651135313
  • Upwork Job ID: 2013888257651135313
  • Last Price Increase: 2026-01-28
  • Automatic offers:
    • abzokhattab | Contributor | 110321632
Issue OwnerCurrent Issue Owner: @JmillsExpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jan 19, 2026
  2. melvin-bot commented on Jan 19, 2026

    @melvin-bot

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

  3. daledah commented on Jan 19, 2026

    @daledah
    Contributor

    Proposal

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

    The filters counter incorrectly shows "(1)" despite no filter being applied to the search results. Additionally, the "Reset Filters" option is not displayed because no filter is actually applied.

    What is the root cause of that problem?

    The issue is in SearchFiltersBar.tsx. The hiddenSelectedFilters count is calculated using searchAdvancedFiltersForm which is the raw form state from Onyx, instead of the applied filters from queryJSON.

    const hiddenSelectedFilters = useMemo(() => {
    const advancedSearchFiltersKeys = typeFiltersKeys.flat();
    const exposedFiltersKeys = new Set(
    filters.flatMap((filter) => {
    const dateFilterKey = DATE_FILTER_KEYS.find((key) => filter.filterKey.startsWith(key));
    if (dateFilterKey) {
    return dateFilterKey;
    }
    return filter.filterKey;
    }),
    );
    const hiddenFilters = advancedSearchFiltersKeys.filter((key) => !exposedFiltersKeys.has(key as SearchAdvancedFiltersKey));
    const hasReportFields = Object.keys(searchAdvancedFiltersForm).some(
    (key) => key.startsWith(CONST.SEARCH.REPORT_FIELD.GLOBAL_PREFIX) && !key.startsWith(CONST.SEARCH.REPORT_FIELD.NOT_PREFIX),
    );
    return hiddenFilters.filter((key) => {
    const dateFilterKey = DATE_FILTER_KEYS.find((dateKey) => key === dateKey);
    if (dateFilterKey) {
    return searchAdvancedFiltersForm[`${dateFilterKey}On`] ?? searchAdvancedFiltersForm[`${dateFilterKey}After`] ?? searchAdvancedFiltersForm[`${dateFilterKey}Before`];
    }
    if (key === CONST.SEARCH.SYNTAX_FILTER_KEYS.REPORT_FIELD) {
    return hasReportFields;
    }
    const amountFilterKey = AMOUNT_FILTER_KEYS.find((amountKey) => key === amountKey);
    if (amountFilterKey) {
    return (
    searchAdvancedFiltersForm[`${amountFilterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.EQUAL_TO}`] ??
    searchAdvancedFiltersForm[`${amountFilterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.GREATER_THAN}`] ??
    searchAdvancedFiltersForm[`${amountFilterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.LESS_THAN}`]
    );
    }
    return searchAdvancedFiltersForm[key as SearchAdvancedFiltersKey];
    });
    }, [searchAdvancedFiltersForm, filters, typeFiltersKeys]);

    The searchAdvancedFiltersForm is updated as soon as the user saves a sub-filter, even before they tap "View Results" to apply the filters. This causes the counter to show filters that haven't been applied yet.

    However, filterFormValues (obtained from useFilterFormValues(queryJSON) at line 102) correctly represents the filters that are actually applied to the search, as it's derived from the URL query:

    const filterFormValues = useFilterFormValues(queryJSON);

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

    Change hiddenSelectedFilters to use filterFormValues instead of searchAdvancedFiltersForm when calculating the filter count:

    --- a/src/components/Search/SearchPageHeader/SearchFiltersBar.tsx
    +++ b/src/components/Search/SearchPageHeader/SearchFiltersBar.tsx
    @@ -724,18 +724,18 @@ function SearchFiltersBar({
             const hasReportFields = Object.keys(searchAdvancedFiltersForm).some(
                 (key) => key.startsWith(CONST.SEARCH.REPORT_FIELD.GLOBAL_PREFIX) && !key.startsWith(CONST.SEARCH.REPORT_FIELD.NOT_PREFIX),
             );
     
             return hiddenFilters.filter((key) => {
                 const dateFilterKey = DATE_FILTER_KEYS.find((dateKey) => key === dateKey);
                 if (dateFilterKey) {
    -                return searchAdvancedFiltersForm[`${dateFilterKey}On`] ?? searchAdvancedFiltersForm[`${dateFilterKey}After`] ?? searchAdvancedFiltersForm[`${dateFilterKey}Before`];
    +                return filterFormValues[`${dateFilterKey}On`] ?? filterFormValues[`${dateFilterKey}After`] ?? filterFormValues[`${dateFilterKey}Before`];
                 }
     
                 if (key === CONST.SEARCH.SYNTAX_FILTER_KEYS.REPORT_FIELD) {
                     return hasReportFields;
                 }
     
                 const amountFilterKey = AMOUNT_FILTER_KEYS.find((amountKey) => key === amountKey);
                 if (amountFilterKey) {
                     return (
    -                    searchAdvancedFiltersForm[`${amountFilterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.EQUAL_TO}`] ??
    -                    searchAdvancedFiltersForm[`${amountFilterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.GREATER_THAN}`] ??
    -                    searchAdvancedFiltersForm[`${amountFilterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.LESS_THAN}`]
    +                    filterFormValues[`${amountFilterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.EQUAL_TO}`] ??
    +                    filterFormValues[`${amountFilterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.GREATER_THAN}`] ??
    +                    filterFormValues[`${amountFilterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.LESS_THAN}`]
                     );
                 }
     
    -            return searchAdvancedFiltersForm[key as SearchAdvancedFiltersKey];
    +            return filterFormValues[key as SearchAdvancedFiltersKey];
             });
    -    }, [searchAdvancedFiltersForm, filters, typeFiltersKeys]);
    +    }, [filterFormValues, filters, typeFiltersKeys]);

    This ensures the counter only reflects filters that have been actually applied to the search (via "View Results"), not intermediate form states.

    What alternative solutions did you explore? (Optional)

    Another approach would be to clear the searchAdvancedFiltersForm when navigating back without saving, but this would be more complex and could affect other parts of the filter flow. Using filterFormValues (derived from the applied query) is a cleaner solution as it correctly represents the actual state of applied filters.

  4. etCoderDysto commented on Jan 19, 2026

    @etCoderDysto
    Contributor

    Proposal

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

    Filters counter is displayed despite no filter being applied

    What is the root cause of that problem?

    When user clicks Reset button, resetChanges is called, and we set the selected items to empty array

    const resetChanges = useCallback(() => {
    setSelectedItems([]);
    }, []);
    const applyChanges = useCallback(() => {
    updateAdvancedFilters({has: selectedItems});
    Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS.getRoute());
    }, [selectedItems]);

    When user clicks save button, updateAdvancedFilters will be called and has key will be set to empty array

    Then when we try to calculate hiddenSelectedFilters, if searchAdvancedFiltersForm["has"] exists and since we have assigned empty array to "has" key the condition will be true and "has" filter will be included in hiddenSelectedFilters, and we show 1 on filters counter

    return searchAdvancedFiltersForm[key as SearchAdvancedFiltersKey];

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

    We should set "has" key to null if selectedItems.length === 0 when we call updateAdvancedFilters

    const resetChanges = useCallback(() => {
    setSelectedItems([]);
    }, []);
    const applyChanges = useCallback(() => {
    updateAdvancedFilters({has: selectedItems});
    Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS.getRoute());
    }, [selectedItems]);

    updateAdvancedFilters({has: selectedItems.length > 0 ? selectedItems : null});
    

    We should make similar changes for all the filters where this issue happens

    What alternative solutions did you explore? (Optional)

    We can map empty array search filter values to null inside updateAdvancedFilters to handle the issue globally.

    function updateAdvancedFilters(values: Nullable<Partial<FormOnyxValues<typeof ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM>>>, shouldUseOnyxSetMethod = false) {
    if (shouldUseOnyxSetMethod) {
    Onyx.set(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, values);
    return;
    }

    function updateAdvancedFilters(values: Nullable<Partial<FormOnyxValues<typeof ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM>>>, shouldUseOnyxSetMethod = false) {
        const cleanedValues = Object.fromEntries(
            Object.entries(values ?? {}).map(([key, value]) => {
                if (Array.isArray(value) && value.length === 0) {
                    return [key, null];
                }
                return [key, value];
            }),
        );
    
        if (shouldUseOnyxSetMethod) {
            Onyx.set(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, cleanedValues);
            return;
        }
        Onyx.merge(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, cleanedValues);
    }
    

    Or
    We can filter out empty array search filter values here

    const filteredValue = searchAdvancedFiltersForm[key as SearchAdvancedFiltersKey];
                if (Array.isArray(fitlerdValue)) {
                    return fitlerdValue.length > 0;
                }
                return filteredValue;
    

    return searchAdvancedFiltersForm[key as SearchAdvancedFiltersKey];

  5. annaweber830 commented on Jan 19, 2026

    @annaweber830
    Contributor

    Proposal

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

    Filters counter shouldn´t be displayed when no filter was applied.

    What is the root cause of that problem?

    The counter is being computed from the draft advanced filters form state (SEARCH_ADVANCED_FILTERS_FORM), which is updated as soon as a nested filter screen “saves” back to the advanced filters UI. When the user exits the advanced filters flow without applying, that draft state can remain “dirty”, so the counter reflects draft changes rather than the applied search query.

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

    Compute the Filters counter from the applied search state (the current queryJSON / URL query) instead of the draft Onyx form.
    Specifically, derive “active filters” using the same query-to-form mapping used elsewhere (e.g., useFilterFormValues(queryJSON)), and count hidden filters from that applied set.
    This ensures the counter only appears when filters are actually applied to the search results.

    const hasReportFields = Object.keys(searchAdvancedFiltersForm).some(
    (key) => key.startsWith(CONST.SEARCH.REPORT_FIELD.GLOBAL_PREFIX) && !key.startsWith(CONST.SEARCH.REPORT_FIELD.NOT_PREFIX),
    );
    return hiddenFilters.filter((key) => {
    const dateFilterKey = DATE_FILTER_KEYS.find((dateKey) => key === dateKey);
    if (dateFilterKey) {
    return searchAdvancedFiltersForm[`${dateFilterKey}On`] ?? searchAdvancedFiltersForm[`${dateFilterKey}After`] ?? searchAdvancedFiltersForm[`${dateFilterKey}Before`];
    }
    if (key === CONST.SEARCH.SYNTAX_FILTER_KEYS.REPORT_FIELD) {
    return hasReportFields;
    }
    const amountFilterKey = AMOUNT_FILTER_KEYS.find((amountKey) => key === amountKey);
    if (amountFilterKey) {
    return (
    searchAdvancedFiltersForm[`${amountFilterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.EQUAL_TO}`] ??
    searchAdvancedFiltersForm[`${amountFilterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.GREATER_THAN}`] ??
    searchAdvancedFiltersForm[`${amountFilterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.LESS_THAN}`]
    );
    }
    return searchAdvancedFiltersForm[key as SearchAdvancedFiltersKey];
    });
    }, [searchAdvancedFiltersForm, filters, typeFiltersKeys]);

    const hasReportFields = Object.keys(filterFormValues).some(
               (key) => key.startsWith(CONST.SEARCH.REPORT_FIELD.GLOBAL_PREFIX) && !key.startsWith(CONST.SEARCH.REPORT_FIELD.NOT_PREFIX),
           );
    
           return hiddenFilters.filter((key) => {
               const dateFilterKey = DATE_FILTER_KEYS.find((dateKey) => key === dateKey);
               if (dateFilterKey) {
                   return filterFormValues[`${dateFilterKey}On`] ?? filterFormValues[`${dateFilterKey}After`] ?? filterFormValues[`${dateFilterKey}Before`];
               }
    
               if (key === CONST.SEARCH.SYNTAX_FILTER_KEYS.REPORT_FIELD) {
                   return hasReportFields;
               }
    
               const amountFilterKey = AMOUNT_FILTER_KEYS.find((amountKey) => key === amountKey);
               if (amountFilterKey) {
                   return (
                       filterFormValues[`${amountFilterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.EQUAL_TO}`] ??
                       filterFormValues[`${amountFilterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.GREATER_THAN}`] ??
                       filterFormValues[`${amountFilterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.LESS_THAN}`]
                   );
               }
    
               return filterFormValues[key as SearchAdvancedFiltersKey];
           });
       }, [filterFormValues, filters, typeFiltersKeys]);
    

    What alternative solutions did you explore? (Optional)

  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jan 21, 2026
  7. changed the title [-]Reports - Filters counter is displayed despite no filter being applied.[/-] [+][$250] Reports - Filters counter is displayed despite no filter being applied.[/+] on Jan 21, 2026
  8. melvin-bot commented on Jan 21, 2026

    @melvin-bot
  9. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jan 21, 2026
  10. melvin-bot commented on Jan 21, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @ikevin127 (External)

  11. 34 remaining items

  12. JmillsExpensify commented on Feb 21, 2026

    @JmillsExpensify
    Contributor

    Payment summary:

  13. JmillsExpensify commented on Feb 21, 2026

    @JmillsExpensify
    Contributor

    Created the regression test. We'll circle back on this one once the regression test passes.

  14. abzokhattab commented on Feb 21, 2026

    @abzokhattab
    Contributor

    Thanks @JmillsExpensify i am paid with new dot can we update the summary

  15. JmillsExpensify commented on Feb 21, 2026

    @JmillsExpensify
    Contributor

    Sure thing. Done!

  16. abzokhattab commented on Feb 28, 2026

    @abzokhattab
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: https://github.com/Expensify/App/pull/78293/changes#r2866930016

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: NA

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Test:

    1. Open app.
    2. Navigate to "Reports" > "Expenses"
    3. Note that no count is displayed on "Filters"
    4. Open the "Filters" tab.
    5. Open a filter that is not displayed in the main filters bar (For example: Has)
    6. Tap on "Category" and tap on "Save"
    7. When redirected to the general filters tab, tap on the arrow on the top left corner, without saving the search or without
    8. tapping on "View Results" before.
    9. Verify that: filter is not applied, as it wasn´t saved, and filters count isn't displayed.

    Do we agree 👍 or 👎

  17. twisterdotcom commented on Feb 28, 2026

    @twisterdotcom
    Contributor

    @abzokhattab has submitted payment for this report on ND here.

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

    Zapier Logs Run ID: 00040eee-0035-a9d4-6b36-97ac8b37bec4
  18. garrettmknight commented on Mar 6, 2026

    @garrettmknight
    Contributor

    $250 approved for @daledah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions