Skip to content

[Due for payment 2025-11-07] [$250] Report - Saved filter is not shown checked after refresh. #70189

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: V9.2.3-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: #70012
Email or phone of affected tester (no customers): Slottwo1 bxvb@gmail.com
Issue reported by: Applause Internal Team
Device used: Redminote 10s android 13
App Component: User Settings

Action Performed:

  1. Go to https://staging.new.expensify.com/home
  2. Go to reports - advanced filter - paid
  3. Select this month radio button and save search
  4. Open paid
  5. Refresh the page
  6. Note this month radio button selected is not shown
  7. Reopen the page and note now radio button selected is shown

Expected Result:

Saved filter must be shown checked after refresh.

Actual Result:

Saved filter is not shown checked after refresh.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021968225820993416364
  • Upwork Job ID: 1968225820993416364
  • Last Price Increase: 2025-09-24
Issue OwnerCurrent Issue Owner: @getusha

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 9, 2025
  2. melvin-bot commented on Sep 9, 2025

    @melvin-bot

    Triggered auto assignment to @sonialiap (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 Sep 9, 2025

    @daledah
    Contributor

    Proposal

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

    Saved filter is not shown checked after refresh.

    What is the root cause of that problem?

    The component uses an “uncontrolled” internal state dateValues, initialized from defaultDateValues only once at mount.

    After a reload, defaultDateValues may change after the component has rendered, but dateValues does not automatically update, so SingleSelectListItem’s isSelected (which depends on dateValues) gets out of sync with the new data.

    const [dateValues, setDateValues] = useState<SearchDateValues>(defaultDateValues);

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

    We should set the dateValues when the defaultDateValues changes

        useEffect(() => {
            setDateValues(defaultDateValues);
        }, [defaultDateValues]);
    

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    None

    What alternative solutions did you explore? (Optional)

    We can separate user interactions from default behavior, and compute the final date value dynamically like the pattern what we already used in Search component.

    IMO the dateValue is very simple to compute so this approach is a bit overkill.

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  4. dmkt9 commented on Sep 9, 2025

    @dmkt9
    Contributor

    Proposal

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

    Saved filter is not shown checked after refresh.

    What is the root cause of that problem?

    1. The dateValues state is initialized with defaultDateValues via useState:
      const [dateValues, setDateValues] = useState<SearchDateValues>(defaultDateValues);
    2. However, since searchAdvancedFiltersForm is undefined during the initial render, defaultDateValues does not contain the expected values:
      const [searchAdvancedFiltersForm] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, {canBeMissing: true});
      const [selectedDateModifier, setSelectedDateModifier] = useState<SearchDateModifier | null>(null);
      const defaultDateValues = {
      [CONST.SEARCH.DATE_MODIFIERS.ON]: searchAdvancedFiltersForm?.[`${dateKey}${CONST.SEARCH.DATE_MODIFIERS.ON}`],
      [CONST.SEARCH.DATE_MODIFIERS.BEFORE]: searchAdvancedFiltersForm?.[`${dateKey}${CONST.SEARCH.DATE_MODIFIERS.BEFORE}`],
      [CONST.SEARCH.DATE_MODIFIERS.AFTER]: searchAdvancedFiltersForm?.[`${dateKey}${CONST.SEARCH.DATE_MODIFIERS.AFTER}`],
      };

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

    We should avoid initializing the state this way. Instead, use defaultDateValues as a fallback value. This ensures defaultDateValues serves its intended role as a default and eliminates the need for multiple renders to reset dateValues.

    const [dateValues, setDateValues] = useState<SearchDateValues>(defaultDateValues);
    const setDateValue = useCallback((dateModifier: SearchDateModifier, value: string | undefined) => {
    setDateValues((prevDateValues) => {

    const [dateValues = defaultDateValues, setDateValues] = useState<SearchDateValues>();
    const setDateValue = useCallback(
        (dateModifier: SearchDateModifier, value: string | undefined) => {
            setDateValues((prevDateValues = defaultDateValues) => {

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    NA

    What alternative solutions did you explore? (Optional)

    NA

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

    2025-09-09.18-36-39.mp4
  5. bernhardoj commented on Sep 9, 2025

    @bernhardoj
    Contributor

    Proposal

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

    Selected date filter is not checked/selected after refresh.

    What is the root cause of that problem?

    The value is initialized from defaultDateValues.

    const [dateValues, setDateValues] = useState<SearchDateValues>(defaultDateValues);

    The defaultDateValues is derived from SEARCH_ADVANCED_FILTERS_FORM onyx data.

    const [searchAdvancedFiltersForm] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, {canBeMissing: true});
    const [selectedDateModifier, setSelectedDateModifier] = useState<SearchDateModifier | null>(null);
    const defaultDateValues = {
    [CONST.SEARCH.DATE_MODIFIERS.ON]: searchAdvancedFiltersForm?.[`${dateKey}${CONST.SEARCH.DATE_MODIFIERS.ON}`],
    [CONST.SEARCH.DATE_MODIFIERS.BEFORE]: searchAdvancedFiltersForm?.[`${dateKey}${CONST.SEARCH.DATE_MODIFIERS.BEFORE}`],
    [CONST.SEARCH.DATE_MODIFIERS.AFTER]: searchAdvancedFiltersForm?.[`${dateKey}${CONST.SEARCH.DATE_MODIFIERS.AFTER}`],
    };

    However, after refresh, the data is still loading, so it's undefined, and the selected item is not checked.

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

    We have 2 options.

    First of all, we need to get the loading state of the onyx data.

    const [searchAdvancedFiltersForm, searchAdvancedFiltersFormMetadata] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, {canBeMissing: true});
    const isSearchAdvancedFiltersFormLoading = isLoadingOnyxValue(searchAdvancedFiltersFormMetadata);

    For the 1st option, we can use this loading state as the component key, so it remounts when the key changes.

    <SearchDatePresetFilterBase
    ref={searchDatePresetFilterBaseRef}
    defaultDateValues={defaultDateValues}
    selectedDateModifier={selectedDateModifier}
    onSelectDateModifier={setSelectedDateModifier}
    presets={presets}
    />

    key={isSearchAdvancedFiltersFormLoading}

    For the 2nd option, we can update the value state once the loading completes.

    First, pass the loading state to SearchDatePresetFilterBase.

    isSearchAdvancedFiltersFormLoading={isSearchAdvancedFiltersFormLoading}

    Then, in SearchDatePresetFilterBase, update the state when the loading completes.

    useEffect(() => {
        if (isSearchAdvancedFiltersFormLoading) {
            return;
        }
        setDateValues(defaultDateValues)
    }, [isSearchAdvancedFiltersFormLoading]);

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    N/A

  6. melvin-bot commented on Sep 12, 2025

    @melvin-bot

    @sonialiap Whoops! This issue is 2 days overdue. Let's get this updated quick!

  7. melvin-bot commented on Sep 16, 2025

    @melvin-bot

    @sonialiap 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  8. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 17, 2025
  9. changed the title [-]Report - Saved filter is not shown checked after refresh.[/-] [+][$250] Report - Saved filter is not shown checked after refresh.[/+] on Sep 17, 2025
  10. melvin-bot commented on Sep 17, 2025

    @melvin-bot
  11. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Sep 17, 2025
  12. 32 remaining items

  13. melvin-bot commented on Oct 31, 2025

    @melvin-bot

    @bernhardoj / @getusha @sonialiap The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  14. melvin-bot commented on Nov 7, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@sonialiap)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1968225820993416364/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  15. sonialiap commented on Nov 10, 2025

    @sonialiap
    Contributor

    Payment summary:
    @bernhardoj $250 please request in NewDot
    @getusha $250 please request in NewDot - please complete the checklist

  16. bernhardoj commented on Nov 10, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  17. getusha commented on Nov 11, 2025

    @getusha
    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/65518/files#r2513645753

    • [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: N/a

    • [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.

    I think we can add a test since this is something that could easily slip.

    Regression Test Proposal

    Test:

    1. Go to reports - advanced filter - paid
    2. Select this month radio button and save search
    3. Open Paid
    4. Refresh the page
    5. Verify that the correct value is selected

    Do we agree 👍 or 👎

  18. quinthar commented on Nov 19, 2025

    @quinthar
    Contributor

    Approved $250 to @getusha

  19. garrettmknight commented on Nov 21, 2025

    @garrettmknight
    Contributor

    $250 approved for @bernhardoj

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