Skip to content

[Due for payment 2025-05-22] [$250] mWeb - Device´s back button has to be used twice to return from chat to inbox after a search #58946

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.1.17-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
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): ibellicotest+437@gmail.com
Issue reported by: Applause Internal Team
Device used: Motorola MotoG60 - Android 12 - Chrome
App Component: Other

Action Performed:

  1. Open the staging.new.expensify.com website.
  2. Open any chat.
  3. Tap on the search icon on the top right corner.
  4. Tap on "Search on this chat"
  5. Write any word that will trigger a result.
  6. When redirected to result, use device´s back button to return to chat.
  7. Use device´s back button to return to inbox.
  8. Check if you are automatically redirected to inbox or if device´s back button has to be used again.
  9. Open the chat again and tap on the search icon.
  10. Select any chat from the list displayed.
  11. Use device´s back button to return to previous chat,
  12. Use device´s back button to return to inbox.
  13. Check if you are automatically redirected to inbox or if device´s back button has to be used again.

Expected Result:

When returning to chat after a search, using device´s back button should redirect to inbox.

Actual Result:

User has to use device´s back button twice to navigate from chat to inbox after returning from a 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

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021904248795597596858
  • Upwork Job ID: 1904248795597596858
  • Last Price Increase: 2025-04-28
  • Automatic offers:
    • truph01 | Contributor | 107135909
Issue OwnerCurrent Issue Owner: @NicMendonca

Activity

  1. added
    Bug
    Daily
    on Mar 22, 2025
  2. melvin-bot commented on Mar 22, 2025

    @melvin-bot

    Triggered auto assignment to @NicMendonca (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. truph01 commented on Mar 22, 2025

    @truph01
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-03-22 09:17:48 UTC.

    Proposal

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

    • User has to use device´s back button twice to navigate from chat to inbox after returning from a search.

    What is the root cause of that problem?

    window.history.pushState({shouldGoBack: true}, '', null);

    • When the modal closes, there's logic to pop this extra state — essentially undoing the push:

    window.history.back();

    • But, in case of this bug, the window.history.back() isn’t called, leaving two identical states in the history. This forces the user to hit the back button twice to return to the inbox screen.

    • But why the window.history.back() is not called? The key issue is that window.history.back() is wrapped inside the hideModal function:

      const hideModal = () => {

      hideModal only triggers after the modal successfully closes. By that point, the current window.history.state isn’t the report screen (step 2) anymore — it’s now the reports page (step 6), which lacks the (window.history.state as WindowState)?.shouldGoBack flag. As a result, window.history.back() never fires.

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

    • We should call the window.history.back() before the user navigates to the report screen:

    Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query: updatedQuery}));

                if ((window.history.state as WindowState)?.shouldGoBack) {
                    window.history.back();
                }
                setTimeout(() => {
                    Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query: updatedQuery}));
                }, 0);
    
    • And we need to do the same in here:

    if (item?.reportID) {
    Navigation.navigateToReportWithPolicyCheck({reportID: item?.reportID});
    } else if ('login' in item) {
    navigateToAndOpenReport(item.login ? [item.login] : [], false);
    }

                    if ((window.history.state as WindowState)?.shouldGoBack) {
                        window.history.back();
                    }
            
                    setTimeout(()=>{
                        if (item?.reportID) {
                            Navigation.navigateToReportWithPolicyCheck({reportID: item?.reportID});
                        } else if ('login' in item) {
                            navigateToAndOpenReport(item.login ? [item.login] : [], false);
                        }
                    }, 0)
    
    • Because the bug only appears if isMobileChrome(), so only apply the change if isMobileChrome(). And consider applying the change in here.

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

    • It is platform specific issue, can't add the test.

    What alternative solutions did you explore? (Optional)

    • We can create a backHistory function:
    function backHistory() {
        return new Promise((resolve) => {
            const onPopState = () => {
                window.removeEventListener('popstate', onPopState);
                resolve?.();
            };
    
            window.addEventListener('popstate', onPopState);
    
            // Trigger the back navigation
            window.history.back();
        });
    }

    And update:

    KeyboardUtils.dismiss().then(() => {
    if (item?.reportID) {
    Navigation.navigateToReportWithPolicyCheck({reportID: item?.reportID});
    } else if ('login' in item) {
    navigateToAndOpenReport(item.login ? [item.login] : [], false);
    }
    });

                    backHistory().then(()=>{
                        if (item?.reportID) {
                            Navigation.navigateToReportWithPolicyCheck({reportID: item?.reportID});
                        } else if ('login' in item) {
                            navigateToAndOpenReport(item.login ? [item.login] : [], false);
                        }
                    })
  4. added
    External
    on Mar 24, 2025
  5. melvin-bot commented on Mar 24, 2025

    @melvin-bot
  6. changed the title [-]mWeb - Device´s back button has to be used twice to return from chat to inbox after a search[/-] [+][$250] mWeb - Device´s back button has to be used twice to return from chat to inbox after a search[/+] on Mar 24, 2025
  7. added
    Help Wanted
    on Mar 24, 2025
  8. melvin-bot commented on Mar 24, 2025

    @melvin-bot

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

  9. 65 remaining items

  10. melvin-bot commented on May 15, 2025

    @melvin-bot

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

  11. melvin-bot commented on May 15, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.45-21 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-05-22. 🎊

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

  12. melvin-bot commented on May 15, 2025

    @melvin-bot

    @ahmedGaber93 @NicMendonca @ahmedGaber93 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]

  13. added
    Daily
    and removed
    Weekly
    on May 22, 2025
  14. NicMendonca commented on May 23, 2025

    @NicMendonca
    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:

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

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

    Regression Test Proposal Template
    • [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:

    Test:

    Do we agree 👍 or 👎

  15. NicMendonca commented on May 23, 2025

    @NicMendonca
    Contributor

    Payment summary

    Contributor: @truph01 - $250 paid via Upwork (✅ done!)
    Contributor +: @ahmedGaber93 - $250 paid via NewExpensify

  16. ahmedGaber93 commented on May 25, 2025

    @ahmedGaber93
    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: Applause Internal Team
    • [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/51032/files#r2106293865

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

    Test:

    Android chrome only

    1. Open ND.
    2. Open any chat.
    3. Tap on the search icon on the top right corner.
    4. Tap on "Search on this chat"
    5. Write any word that will trigger a result.
    6. When redirected to result, use device´s back button to return to chat.
    7. Use device´s back button to return to inbox.
    8. Verify: You are automatically redirected to inbox.
    9. Open the chat again and tap on the search icon.
    10. Select any chat from the list displayed.
    11. Use device´s back button to return to previous chat,
    12. Use device´s back button to return to inbox.
    13. Verify: You are automatically redirected to inbox.

    Do we agree 👍 or 👎

  17. NicMendonca commented on May 26, 2025

    @NicMendonca
    Contributor

    Payment summary

    Contributor: @truph01 - $250 paid via Upwork (✅ done!)
    Contributor +: @ahmedGaber93 - $250 paid via NewExpensify

  18. JmillsExpensify commented on Jul 11, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @ahmedGaber93

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions