Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[$1000] Deeplink - No prompt to open in app when navigating to deep link as logged-out web user #25790

Closed
2 of 6 tasks
lanitochka17 opened this issue Aug 23, 2023 · 27 comments
Closed
2 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@lanitochka17
Copy link

lanitochka17 commented Aug 23, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Issue found when executing PR #24638

Action Performed:

  1. Go to staging.new.expensify.com
  2. As signed in user on web, copy code to room and paste it on web browser and navigate to the link
  3. As signed out user on web, repeat Step 2

Expected Result:

Whether user is signed in or signed out on web browser, navigate to new expensify deeplink on web should show a prompt to open ND in app

Actual Result:

When user is signed out on web and navigates to deep link, there is no prompt to open in desktop app

Workaround:

Unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.56-18

Reproducible in staging?: Yes

Reproducible in production?: No

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

Notes/Photos/Videos: Any additional supporting documentation

Bug6174773_20230823_221451.mp4

Expensify/Expensify Issue URL:

Issue reported by: Applause - Internal Team

Slack conversation:

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01f534d2e9aa904030
  • Upwork Job ID: 1694458731220623360
  • Last Price Increase: 2023-08-30
@lanitochka17 lanitochka17 added the DeployBlockerCash This issue or pull request should block deployment label Aug 23, 2023
@OSBotify
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open StagingDeployCash deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@melvin-bot
Copy link

melvin-bot bot commented Aug 23, 2023

Triggered auto assignment to @yuwenmemon (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@yuwenmemon
Copy link
Contributor

I QA'd #24638 - it worked fine and I don't believe what we're seeing here is a deploy blocker. I'm going to reassign this to the bug zero team for triage.

@yuwenmemon yuwenmemon added Weekly KSv2 and removed Hourly KSv2 labels Aug 23, 2023
@yuwenmemon yuwenmemon added Hourly KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Engineering Weekly KSv2 Hourly KSv2 labels Aug 23, 2023
@yuwenmemon yuwenmemon removed their assignment Aug 23, 2023
@yuwenmemon yuwenmemon added the Bug Something is broken. Auto assigns a BugZero manager. label Aug 23, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 23, 2023

Triggered auto assignment to @joekaufmanexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot melvin-bot bot added the Daily KSv2 label Aug 23, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 23, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@joekaufmanexpensify
Copy link
Contributor

Confirmed this works right now on production when signed in or out. It's only on staging that we don't prompt to open the desktop app when deeplinking while signed out.

@joekaufmanexpensify joekaufmanexpensify added the External Added to denote the issue can be worked on by a contributor label Aug 23, 2023
@melvin-bot melvin-bot bot changed the title Deeplink - No prompt to open in app when navigating to deep link as logged-out web user [$1000] Deeplink - No prompt to open in app when navigating to deep link as logged-out web user Aug 23, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 23, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01f534d2e9aa904030

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 23, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 23, 2023

Current assignee @joekaufmanexpensify is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Aug 23, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 24, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@joekaufmanexpensify
Copy link
Contributor

@ArekChr I would think we wouldn't want to close this, no? It seems like a bug that we're not triggering the desktop prompt when logged out on staging.

@ArekChr
Copy link
Contributor

ArekChr commented Aug 25, 2023

Sure, I thought that was intentional.

@napster125
Copy link
Contributor

napster125 commented Aug 25, 2023

Proposal

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

When a user is signed out on the web and attempts to navigate to a deep link, there is no prompt to open the link in the desktop app.

What is the root cause of that problem?

The root cause of this problem is that we are not handling deep links when users are logged out.
You can find the relevant code snippet here:

if (isAuthenticated) {
promptToOpenInDesktopApp();
setHasShownPrompt(true);
} else {
// Navigation state is not set up yet, we're unsure if we should show the deep link prompt or not
if (currentScreen === undefined || isAuthenticated === false) {
return;
}
const preventPrompt = shouldPreventDeeplinkPrompt(currentScreen);
if (preventPrompt === true) {
return;
}
promptToOpenInDesktopApp();
setHasShownPrompt(true);
}

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

To address this issue, I recommend the following changes:

  • Update Conditional Expression
    We need to modify the code by removing the conditional expression that checks for isAuthenticated === false. Since the existing else statement implies that isAuthenticated is false, the conditional is unnecessary.

if (currentScreen === undefined || isAuthenticated === false) {

  • Adjust Denylist for Opening Desktop App
    We need to modify the code by either removing HOME from the DEEPLINK_PROMPT_DENYLIST, or by incorporating the condition navigationRef.current.getState().routes.length === 1. This indicates that these changes are specifically related to the DEEPLINK and do not affect HOME. This condition establishes that if the route length is greater than 1, it signifies a deep link; otherwise, it is not a deep link. These changes are aimed at enabling the desktop app to show a prompt for opening when a user, logged out on the web, navigates to a deep link.

const preventPrompt = shouldPreventDeeplinkPrompt(currentScreen);
if (preventPrompt === true) {

DEEPLINK_PROMPT_DENYLIST: [SCREENS.HOME, SCREENS.SIGN_IN_WITH_APPLE_DESKTOP, SCREENS.SIGN_IN_WITH_GOOGLE_DESKTOP],

  • Modification of Conditional Code Block Adjust the code as follows:
if (currentScreen === undefined) {
  return;
}

const preventPrompt = shouldPreventDeeplinkPrompt(currentScreen);

// navigationRef.current is not null as currentScreen is not undefined. Therefore, we can utilize navigationRef.current.
if (preventPrompt === true && navigationRef.current.getState().routes.length === 1) {
  return;
}

This modification ensures proper handling of the prompt prevention based on the conditions mentioned.

What alternative solutions did you explore? (Optional)

We can remove HOME from the DEEPLINK_PROMPT_DENYLIST, but this might disrupt the original functionality.

P.S.

The existing solution has a potential problem of causing an infinite loop due to a specific section of code. This issue arises from the usage of the useEffect hooks in certain parts of the codebase, where each hook has a dependency on the hasShownPrompt variable. Consequently, when any of these dependencies change, it triggers the useEffect hooks and leads to an infinite loop.

useEffect(() => {
// If we've shown the prompt and still have a listener registered,
// remove the listener and reset its ref to undefined
if (hasShownPrompt && removeListener.current !== undefined) {
removeListener.current();
removeListener.current = undefined;
}
if (isAuthenticated === false) {
setHasShownPrompt(false);
Navigation.isNavigationReady().then(() => {
// Get initial route
const initialRoute = navigationRef.current.getCurrentRoute();
setCurrentScreen(initialRoute.name);
removeListener.current = navigationRef.current.addListener('state', (event) => {
setCurrentScreen(Navigation.getRouteNameFromStateEvent(event));
});
});
}
}, [hasShownPrompt, isAuthenticated]);
useEffect(() => {
// According to the design, we don't support unlink in Desktop app https://github.com/Expensify/App/issues/19681#issuecomment-1610353099
const isUnsupportedDeeplinkRoute = _.some([CONST.REGEX.ROUTES.UNLINK_LOGIN], (unsupportRouteRegex) => {
const routeRegex = new RegExp(unsupportRouteRegex);
return routeRegex.test(window.location.pathname);
});
// Making a few checks to exit early before checking authentication status
if (!isMacOSWeb() || isUnsupportedDeeplinkRoute || CONFIG.ENVIRONMENT === CONST.ENVIRONMENT.DEV || hasShownPrompt) {
return;
}
// We want to show the prompt immediately if the user is already authenticated.
// Otherwise, we want to wait until the navigation state is set up
// and we know the user is on a screen that supports deeplinks.
if (isAuthenticated) {
promptToOpenInDesktopApp();
setHasShownPrompt(true);
} else {
// Navigation state is not set up yet, we're unsure if we should show the deep link prompt or not
if (currentScreen === undefined || isAuthenticated === false) {
return;
}
const preventPrompt = shouldPreventDeeplinkPrompt(currentScreen);
if (preventPrompt === true) {
return;
}
promptToOpenInDesktopApp();
setHasShownPrompt(true);
}
}, [currentScreen, hasShownPrompt, isAuthenticated]);

setHasShownPrompt(false);

setHasShownPrompt(true);

To address this problem, two potential solutions have been identified:

  • Option 1: Removing a specific line of code
    In this option, the problematic line in the codebase is removed. However, it's worth noting that this action could potentially disrupt the logic, which is designed to restrict the opening of the desktop app to a single instance.

setHasShownPrompt(true);

Result:

expensify.issue.1.mp4
  • Option 2: Removing another specific line of code
    Alternatively, this option suggests removing a different line of code. Similarly, this approach might impact the logic that allows the opening of the desktop app after a user has logged in.

setHasShownPrompt(false);

Result:

expensify.issue.2.mp4

Ultimately, the chosen option will depend on the priorities of the project and the desired behavior of the application.

@pradeepmdk
Copy link
Contributor

pradeepmdk commented Aug 25, 2023

Proposal

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

No prompt to open in app when navigating to deep link as logged-out web user

What is the root cause of that problem?

if (currentScreen === undefined || isAuthenticated === false) {

if (isAuthenticated === false) {

Both places we are blocking for non-auth people

This Pr is add this #23673 when social sign-in is enabled

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

we should remove isAuthenticated === false both places and
we should remove SCREENS.HOME as well because SCREENS.HOME is a root path for this allow the path

 const preventPrompt = shouldPreventDeeplinkPrompt(currentScreen); 

and
we should update

if (isAuthenticated === false) {

    + if (!hasShownPrompt) { // update this one
   - setHasShownPrompt(false); and remove this
            Navigation.isNavigationReady().then(() => {
                // Get initial route
                const initialRoute = navigationRef.current.getCurrentRoute();
                setCurrentScreen(initialRoute.name);

                removeListener.current = navigationRef.current.addListener('state', (event) => {
                    setCurrentScreen(Navigation.getRouteNameFromStateEvent(event));
                });
            });
        }

}, [hasShownPrompt, isAuthenticated]);

because when ever hasShownPrompt changes and isAuthenticated === false means it will update again hasShownPrompt as false and again it will ask the popup to open desktop so it will goes to loop.

@joekaufmanexpensify
Copy link
Contributor

Sure, I thought that was intentional.

@ArekChr did you see discussion that said this somewhere? The reason I thought this was not intentional is that when I was testing it the other day, we were not showing the "switch to desktop" prompt to non-authenticated users on staging, but we were on production.

That inconsistency made me think this was likely a regression introduced at recently (unless we made the active decision to change this somewhere).

@joekaufmanexpensify
Copy link
Contributor

Not overdue

@melvin-bot melvin-bot bot removed the Overdue label Aug 28, 2023
@joekaufmanexpensify
Copy link
Contributor

@ArekChr mind sharing your thoughts on this when you have a sec?

@melvin-bot
Copy link

melvin-bot bot commented Aug 30, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@joekaufmanexpensify
Copy link
Contributor

Still pending C+ review

@ArekChr
Copy link
Contributor

ArekChr commented Aug 31, 2023

@joekaufmanexpensify It Looks like this functionality is intended. There were discussions about not prompting redirects when users are logged out on the web app, a related thread here
cc: @cdanwards

@joekaufmanexpensify
Copy link
Contributor

Ah cool. Yep, confirmed here. Closing as this is intended!

@Julesssss
Copy link
Contributor

Julesssss commented Jun 6, 2024

Hi @kbecciv I see you linked to this comment from here, mentioning that the PR wasn't passing tests. I think we are good now, but could you please just take a look to confirm? thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

10 participants