Skip to content

[Due for payment 2025-03-21] [$250] Saved search - Deleting a saved search resets the currently opened search #57749

Closed

Description

@IuliiaHerets

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.1.8-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: Exp
Email or phone of affected tester (no customers): applausetester+ps309@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.3 / Chrome
App Component: Search

Action Performed:

Precondition:

  • There are at least two saved searches.
  1. Go to staging.new.expensify.com
  2. Go to Reports.
  3. Open any saved search.
  4. Click 3-dot menu on the other saved search.
  5. Click Delete.
  6. Delete the saved search.

Expected Result:

The currently opened search view will not be reset.

Actual Result:

The currently opened search view is reset after deleting a saved search.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6760807_1741091449367.20250304_202724.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021897254435294536283
  • Upwork Job ID: 1897254435294536283
  • Last Price Increase: 2025-03-05
  • Automatic offers:
    • nyomanjyotisa | Contributor | 106425080
Issue OwnerCurrent Issue Owner: @zanyrenney

Activity

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

    @melvin-bot

    Triggered auto assignment to @zanyrenney (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. nyomanjyotisa commented on Mar 4, 2025

    @nyomanjyotisa
    Member

    Proposal

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

    Saved search - Deleting a saved search resets the currently opened search

    What is the root cause of that problem?

    We always reset the currently opened search on delete saved search

    const handleDelete = () => {
    deleteSavedSearch(hashToDelete);
    setIsDeleteModalVisible(false);
    clearAdvancedFilters();
    Navigation.navigate(
    ROUTES.SEARCH_ROOT.getRoute({
    query: buildCannedSearchQuery(),
    }),
    );
    };

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

    Only reset the currently opened search if currentSearchHash from useSearchContext is equal to hashToDelete

    const {currentSearchHash} = useSearchContext();
    
        const handleDelete = () => {
            deleteSavedSearch(hashToDelete);
            setIsDeleteModalVisible(false);
    
            if(hashToDelete === currentSearchHash) {
                clearAdvancedFilters();
                Navigation.navigate(
                    ROUTES.SEARCH_ROOT.getRoute({
                        query: buildCannedSearchQuery(),
                    }),
                );
            }
        };
    

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

    N/A

    What alternative solutions did you explore? (Optional)

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Mar 5, 2025
  5. changed the title [-]Saved search - Deleting a saved search resets the currently opened search[/-] [+][$250] Saved search - Deleting a saved search resets the currently opened search[/+] on Mar 5, 2025
  6. melvin-bot commented on Mar 5, 2025

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Mar 5, 2025
  8. melvin-bot commented on Mar 5, 2025

    @melvin-bot

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

  9. zanyrenney commented on Mar 5, 2025

    @zanyrenney
    Contributor

    Adding the external label so we can get some movement here. @allroundexperts please could you take a look at the proposal above and let me know if we want to go forward with that one?

  10. nkdengineer commented on Mar 6, 2025

    @nkdengineer
    Contributor

    Proposal

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

    The currently opened search view is reset after deleting a saved search.

    What is the root cause of that problem?

    We have two bugs

    1. If we delete the saved search that isn't the viewing search, the currently opened search is reset

    The RCA is that we always clear the filter and navigate to the default search

    const handleDelete = () => {
    deleteSavedSearch(hashToDelete);
    setIsDeleteModalVisible(false);
    clearAdvancedFilters();
    Navigation.navigate(
    ROUTES.SEARCH_ROOT.getRoute({
    query: buildCannedSearchQuery(),

    1. If we delete the current saved search, and click on the browser back button, we go back to the deleted saved search query

    The RCA is that we use navigate when navigate to the default search then the delete saved search page still in the navigation stack

    const handleDelete = () => {
    deleteSavedSearch(hashToDelete);
    setIsDeleteModalVisible(false);
    clearAdvancedFilters();
    Navigation.navigate(
    ROUTES.SEARCH_ROOT.getRoute({
    query: buildCannedSearchQuery(),

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

    1. We should check if the current opened search is the delete saved search, we shouldn't clear the filter and navigate to the default search

    2. We should use goBack instead of navigate to remove the delete saved search page in the navigation stack

    if (currentSearchHash === hashToDelete) {
        clearAdvancedFilters();
        Navigation.goBack(
            ROUTES.SEARCH_ROOT.getRoute({
                query: buildCannedSearchQuery(),
            }),
        );
    }
    

    const handleDelete = () => {
    deleteSavedSearch(hashToDelete);
    setIsDeleteModalVisible(false);
    clearAdvancedFilters();
    Navigation.navigate(
    ROUTES.SEARCH_ROOT.getRoute({
    query: buildCannedSearchQuery(),

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

    This is the wrong logic in a hook, so don't need to test

    What alternative solutions did you explore? (Optional)

    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.

  11. allroundexperts commented on Mar 7, 2025

    @allroundexperts
    Contributor

    Thanks for the proposals everyone.

    @Themoonalsofall While your proposal has the correct RCA, you posted the correct solution (using currentSearchHash) only after @nyomanjyotisa's posted there proposal.

    @nkdengineer Your proposal is same as what others posted earlier, with an additional bug that you pointed out.

    As such, I think we should go with the first proposal that had the correct RCA and the solution. I suggest that we create a new issue for the second bug, and you can post your proposal there.

    @nyomanjyotisa's proposal looks good to me.

    🎀 👀 🎀 C+ reviewed

  12. 12 remaining items

  13. nyomanjyotisa commented on Mar 10, 2025

    @nyomanjyotisa
    Member

    The PR is ready
    cc @allroundexperts

  14. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Mar 14, 2025
  15. changed the title [-][$250] Saved search - Deleting a saved search resets the currently opened search[/-] [+][Due for payment 2025-03-21] [$250] Saved search - Deleting a saved search resets the currently opened search[/+] on Mar 14, 2025
  16. melvin-bot commented on Mar 14, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  17. melvin-bot commented on Mar 14, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.12-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2025-03-21. 🎊

    For reference, here are some details about the assignees on this issue:

  18. melvin-bot commented on Mar 14, 2025

    @melvin-bot

    @allroundexperts @zanyrenney @allroundexperts 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]

  19. zanyrenney commented on Mar 21, 2025

    @zanyrenney
    Contributor

    payment summary

    @allroundexperts requires payment through NewDot Manual Requests - please request $250 via ND.
    @nyomanjyotisa requires payment automatic offer (Contributor) - paid $250 via upwork.

  20. allroundexperts commented on Mar 23, 2025

    @allroundexperts
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [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/48566/files#r2009257062

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

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

    Precondition:

    • There are at least two saved searches.

    Test:

    1. Go to Reports.
    2. Open any saved search.
    3. Click the 3-dot menu on the other saved search.
    4. Click Delete.
    5. Delete the saved search.

    Verify that the currently open search view is not reset.

    Do we agree 👍 or 👎

  21. JmillsExpensify commented on Jun 13, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @allroundexperts

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

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions