Skip to content

[HOLD for payment 2025-02-05] [$250] "you've been switched to focus mode" modal after open an expense on the Reports page #55492

Closed

Description

@m-natarajan

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:
Reproducible in staging?: need reproduction
Reproducible in production?: need reproduction
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @puneetlath
Slack conversation (hyperlinked to channel name): retain

Action Performed:

  1. Login to an account
  2. Have several messages received by other users
  3. Open an expense on the report page

Expected Result:

"you've been switched to focus mode" modal should only show this on the Inbox.

Actual Result:

"you've been switched to focus mode" modal appears after open an expense on the Reports page.

Workaround:

unknown

Platforms:

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

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

Screenshots/Videos

Add any screenshot/video evidence

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021881627889773961977
  • Upwork Job ID: 1881627889773961977
  • Last Price Increase: 2025-01-21
  • Automatic offers:
    • truph01 | Contributor | 105829716
Issue OwnerCurrent Issue Owner: @dylanexpensify

Activity

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

    @melvin-bot

    Triggered auto assignment to @dylanexpensify (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 Jan 21, 2025

    @truph01
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-01-22 09:52:50 UTC.

    Proposal

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

    • "you've been switched to focus mode" modal appears after open an expense on the Reports page.

    What is the root cause of that problem?

    • That modal is displaying in Expensify file:

    {focusModeNotification ? <FocusModeNotification /> : null}

    so it will be shown as long as FocusModeNotification is true:

    const [focusModeNotification] = useOnyx(ONYXKEYS.FOCUS_MODE_NOTIFICATION, {initWithStoredValues: false});

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

                <>
                    <AppNavigator authenticated={authenticated} />
                    {shouldShowFocusModeNotification ? <FocusModeNotification /> : null}
                </>
    
    • Introduce a few new variables to handle the shouldShowFocusModeNotification:
        const [focusModeNotification] = useOnyx(ONYXKEYS.FOCUS_MODE_NOTIFICATION, {initWithStoredValues: false});
        const [shouldShowFocusModeNotification, setShouldShowFocusModeNotification] = useState(false);
    
        const tryToTriggerFocusModeModal = useCallback(() => {
            const currentRoute = navigationRef.getCurrentRoute();
            if (focusModeNotification) {
                if (shouldUseNarrowLayout) {
                    if (currentRoute?.name === 'Home') {
                        setShouldShowFocusModeNotification(true);
                    }
                } else {
                    if (currentRoute?.name === 'Report') {
                        setShouldShowFocusModeNotification(true);
                    }
                }
            } else {
                setShouldShowFocusModeNotification(false);
            }
        }, [focusModeNotification, shouldUseNarrowLayout]);
    
    • Finally, trigger the above tryToTriggerFocusModeModal when these two events appear:
    1. When user navigate to Inbox or Report page.

    2. When user already are in the inbox or Report page but the focusModeNotification is updated.

    With the 1st event, we can call it in here.

    With the 2nd event, we can call it in useEffect:

        useEffect(() => {
            tryToTriggerFocusModeModal();
        }, [focusModeNotification]);
    

    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)

    Alternative solution 1:

                    {shouldShowFocusModeNotification ? <FocusModeNotification /> : null}
    
    • Introduce a few new variables to handle the shouldShowFocusModeNotification:
        const [focusModeNotification] = useOnyx(ONYXKEYS.FOCUS_MODE_NOTIFICATION, {initWithStoredValues: false});
        const [shouldShowFocusModeNotification, setShouldShowFocusModeNotification] = useState(false);
    
        const tryToTriggerFocusModeModal = useCallback(() => {
            const currentRoute = navigationRef.getCurrentRoute();
            if (focusModeNotification) {
                if (shouldUseNarrowLayout) {
                    if (currentRoute?.name === 'Home') {
                        setShouldShowFocusModeNotification(true);
                    }
                } else {
                    if (currentRoute?.name === 'Report') {
                        setShouldShowFocusModeNotification(true);
                    }
                }
            } else {
                setShouldShowFocusModeNotification(false);
            }
        }, [focusModeNotification, shouldUseNarrowLayout]);
    
    • Finally, trigger the above tryToTriggerFocusModeModal when these two events appear:
    1. When user navigate to Inbox or Report page.

    2. When user already are in the inbox or Report page but the focusModeNotification is updated.

    With the 1st event, we can call it in here:

        const navigation = useNavigation();
        useEffect(() => {
            const unsubscribe = navigation.addListener('state', () => {
               tryToTriggerFocusModeModal()
            });
            return () => unsubscribe();
        }, [navigation]);
    

    With the 2nd event, we can call it in useEffect:

        useEffect(() => {
            tryToTriggerFocusModeModal();
        }, [focusModeNotification]);
    

    Alternative solution 2:

    • In here add the check:
            const currentRoute = navigationRef.getCurrentRoute();
            if (getIsNarrowLayout()) {
                if (currentRoute?.name !== 'Home') {
                    return;
                }
            } else {
                if (currentRoute?.name !== 'Report') {
                    return;
                }
            }
    
    • Then in here, add:
    
        const navigation = useNavigation();
        useEffect(() => {
            const unsubscribe = navigation.addListener('state', () => {
            PriorityMode.autoSwitchToFocusMode();
            });
            return () => unsubscribe();
        }, [navigation]);
    
    
  4. dylanexpensify commented on Jan 21, 2025

    @dylanexpensify
    Contributor

    Nice one, reviewing today!

  5. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jan 21, 2025
  6. changed the title [-]"you've been switched to focus mode" modal after open an expense on the Reports page[/-] [+][$250] "you've been switched to focus mode" modal after open an expense on the Reports page[/+] on Jan 21, 2025
  7. melvin-bot commented on Jan 21, 2025

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

    @melvin-bot

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

  10. dukenv0307 commented on Jan 22, 2025

    @dukenv0307
    Contributor

    @truph01 Thanks for your proposal. I like your idea, but can we somehow add currentRoute check in tryFocusModeUpdate

    then trigger tryFocusModeUpdate whenever navigation status changes? I think moving FocusModeNotification to NavigationRoot is not a best practise.

  11. 15 remaining items

  12. changed the title [-][$250] "you've been switched to focus mode" modal after open an expense on the Reports page[/-] [+][HOLD for payment 2025-02-05] [$250] "you've been switched to focus mode" modal after open an expense on the Reports page[/+] on Jan 29, 2025
  13. melvin-bot commented on Jan 29, 2025

    @melvin-bot

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

  14. melvin-bot commented on Jan 29, 2025

    @melvin-bot

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

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

  15. melvin-bot commented on Jan 29, 2025

    @melvin-bot

    @dukenv0307 @dylanexpensify @dukenv0307 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]

  16. dukenv0307 commented on Jan 29, 2025

    @dukenv0307
    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
    • 2b. Reported on staging (deploy blocker)
    • 2c. 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: It's the edge case so I think no need to comment on the offending PR.

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in https://app.slack.com/client/E047TPA624F/C01GTK53T8Q 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 https://github.com/Expensify/App/blob/main/contributingGuides/REGRESSION_TEST_BEST_PRACTICES.md steps using the template below to ensure the same bug will not reach production again. Yes

    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

    Test:

    1. Log in to an account and ensure the following conditions are met:

    The nvp_priorityMode setting is set to false.
    There are fewer than 30 reports.
    The user is in default mode.
    Navigate to the "Reports" tab.

    1. Open the FAB menu and create enough expenses to bring the total number of reports to 30 or more.
    2. Confirm that no "You've been switched to focus mode" modal appears.
    3. Go to the "Inbox" tab.
    4. Verify that the "You've been switched to focus mode" modal is displayed.

    Do we agree 👍 or 👎

  17. dylanexpensify commented on Feb 5, 2025

    @dylanexpensify
    Contributor

    Payment summary:

    Contributor: @truph01 $250 via Upwork
    Contributor+: @dukenv0307 $250 via NewDot

    Please apply/request!

  18. dylanexpensify commented on Feb 5, 2025

    @dylanexpensify
    Contributor

    Done

  19. JmillsExpensify commented on Feb 20, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @dukenv0307

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