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

[HOLD for payment 2025-01-02] [HOLD for payment 2024-12-30] [$500] Onboarding flow is not showing upon first sign in #54322

Closed
8 tasks
mountiny opened this issue Dec 18, 2024 · 52 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@mountiny
Copy link
Contributor

mountiny commented Dec 18, 2024

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?:
Reproducible in production?:
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:
Slack conversation (hyperlinked to channel name):

Action Performed:

Break down in numbered steps

  1. Sign into a new account
  2. The onboarding modal is not showing
  3. Refresh the page
  4. The modal is shown

Expected Result:

Describe what you think should've happened

The modal should be shown first upon signing the user should not be allowed to skip it

Actual Result:

Describe what actually happened

The user is not presented with the modal

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

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

2024-12-18_11-11-20.mp4
Add any screenshot/video evidence

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021869459467806061602
  • Upwork Job ID: 1869459467806061602
  • Last Price Increase: 2024-12-18
  • Automatic offers:
    • nkdengineer | Contributor | 105391259
Issue OwnerCurrent Issue Owner: @bfitzexpensify
@mountiny mountiny added DeployBlockerCash This issue or pull request should block deployment External Added to denote the issue can be worked on by a contributor Hourly KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 18, 2024
@melvin-bot melvin-bot bot changed the title Onboarding flow is not showing upon first sign in [$250] Onboarding flow is not showing upon first sign in Dec 18, 2024
Copy link

melvin-bot bot commented Dec 18, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 18, 2024
Copy link

melvin-bot bot commented Dec 18, 2024

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

Copy link

melvin-bot bot commented Dec 18, 2024

Triggered auto assignment to @bfitzexpensify (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.

Copy link

melvin-bot bot commented Dec 18, 2024

Triggered auto assignment to @stitesExpensify (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link

melvin-bot bot commented Dec 18, 2024

💬 A slack conversation has been started in #expensify-open-source

@mountiny mountiny self-assigned this Dec 18, 2024
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.

@mountiny
Copy link
Contributor Author

I will take it over

@mountiny
Copy link
Contributor Author

@trjExpensify has confirmed that the OpenApp returns the hasCompletedGuidedSetupFlow as false so this seems to be app issue indeed

@trjExpensify
Copy link
Contributor

Yep, here's a vid of that:

2024-12-18_19-08-34.mp4

@Shahidullah-Muffakir
Copy link
Contributor

Working on it here, #53724

@mountiny mountiny changed the title [$250] Onboarding flow is not showing upon first sign in [$500] Onboarding flow is not showing upon first sign in Dec 18, 2024
Copy link

melvin-bot bot commented Dec 18, 2024

Upwork job price has been updated to $500

@Shahidullah-Muffakir
Copy link
Contributor

In case this helps others pinpoint the root cause:

I tested on all supported platforms, and the onboarding flow modal works correctly on mWeb, native, and desktop.

However, on macOS with Chrome and Safari, the onboarding modal does not appear when the browser window is large., if we refresh the page after signup, the modal appears as expected. or If I reduce the window width (narrowLayout) before starting the signup, the modal works fine on both browsers.

@nkdengineer
Copy link
Contributor

nkdengineer commented Dec 18, 2024

Edited by proposal-police: This proposal was edited at 2024-12-19 11:55:34 UTC.

Proposal

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

Describe what actually happened

What is the root cause of that problem?

After the user signs in, we must wait for the onboarding data to be loaded before starting an onboarding flow here.

if (!NativeModules.HybridAppModule && isOnboardingCompleted === false) {
OnboardingFlow.startOnboardingFlow(isPrivateDomain);
}
}, [

And we will reset the root state here

navigationRef.resetRoot({
...navigationRef.getRootState(),
...adaptedState,
stale: true,

But at this time, we also have a logic to change the navigation on the ReportScreen here

const lastAccessedReportID = ReportUtils.findLastAccessedReport(!canUseDefaultRooms, !!route.params.openOnAdminRoom, activeWorkspaceID)?.reportID;
// It's possible that reports aren't fully loaded yet
// in that case the reportID is undefined
if (!lastAccessedReportID) {
return;
}
Log.info(`[ReportScreen] no reportID found in params, setting it to lastAccessedReportID: ${lastAccessedReportID}`);
navigation.setParams({reportID: lastAccessedReportID});

While the param is updating in the route, this useEffect is triggered again, and navigation.setParams is called again with the outdated state which can cause the navigation stack to be overridden to the old state.

Then the onboarding is not added to the navigation stack which causes the bug to occur and that is the reason why it only happens on web/desktop

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

We can have a temporary fix by creating a ref to store the lastAccessedReportID and return early to prevent this logic is called again while the route is updating.

const lastAccessedReportID = ReportUtils.findLastAccessedReport(!canUseDefaultRooms, !!route.params.openOnAdminRoom, activeWorkspaceID)?.reportID;
// It's possible that reports aren't fully loaded yet
// in that case the reportID is undefined
if (!lastAccessedReportID) {
return;
}
Log.info(`[ReportScreen] no reportID found in params, setting it to lastAccessedReportID: ${lastAccessedReportID}`);
navigation.setParams({reportID: lastAccessedReportID});

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

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.

@nkdengineer
Copy link
Contributor

@mountiny While debugging, I saw we called startOnboardingFlow but

function startOnboardingFlow(isPrivateDomain?: boolean) {

When I log the state here, the onboarding isn't in the navigation stack.

function parseAndLogRoute(state: NavigationState) {

I wrote a proposal here based on what I logged but I cannot verify this now because SignUpUser returns error.

Screenshot 2024-12-19 at 03 24 49

@s77rt
Copy link
Contributor

s77rt commented Dec 18, 2024

@nkdengineer Thanks for the proposal but it doesn't answer why this works on mWeb?

@bernhardoj
Copy link
Contributor

Here you can see the log where after "doing action" for the onboarding modal gives us the correct state but right after that state is overwritten

I think this is what happen.

Looking at the code, setParams returns a new state containing the routes (with the updated params) from the state that is passed to getStateForAction. But looks like the state passed to the function doesn't have the onboarding route.

return {
  ...state,
  routes: state.routes.map((r, i) =>
    i === index
      ? { ...r, params: { ...r.params, ...action.payload.params } }
      : r
  ),
};

Here, we pass the state to getStateForAction from the nextState variable.
https://github.com/react-navigation/react-navigation/blob/5a8d0f65e0d118317417cf76749e6f28fc50c02a/packages/core/src/useNavigationBuilder.tsx#L545-L551

The nextState initial value will be the same as state.

https://github.com/react-navigation/react-navigation/blob/5a8d0f65e0d118317417cf76749e6f28fc50c02a/packages/core/src/useNavigationBuilder.tsx#L477-L485

let state =
  // If the state isn't initialized, or stale, use the state we initialized instead
  // The state won't update until there's a change needed in the state we have initalized locally
  // So it'll be `undefined` or stale until the first navigation event happens
  isStateInitialized(currentState)
    ? (currentState as State)
    : (initializedState as State);

let nextState: State = state;

state can either be currentState or intiailizedState. currentState contains the updated state of each action and we expect state to contain the new state from the resetRoot action. But when we do the resetRoot, we set the stale to true.

navigationRef.resetRoot({
...navigationRef.getRootState(),
...adaptedState,
stale: true,
} as PartialState<NavigationState>);

It makes isStateInitialized(currentState) return false, so state contains the initializedState value which doesn't have the onboarding route.
https://github.com/react-navigation/react-navigation/blob/5a8d0f65e0d118317417cf76749e6f28fc50c02a/packages/core/src/useNavigationBuilder.tsx#L355-L360

This can easliy be reproduced with this code.

<Pressable onPress={() => {
    navigationRef.resetRoot({routes: [{name: BottomTabNavigator}, {name: Report}, {name: Report}]});
    navigation.setParams({reportID: '1'});
}}>
  <Text>Test</Text>
</Pressable>

@blazejkustra
Copy link
Contributor

Just FYI, we are looking into this issue with SWM's navigation experts. We suspect it comes from a PR where native stacks were introduced. We'll keep you updated

@s77rt
Copy link
Contributor

s77rt commented Dec 19, 2024

The bug may simply be due to the nature of dispatching events being async:

navigationRef.resetRoot({
    routes: [
        {
            name: 'BottomTabNavigator',
        },

        {
            name: 'OnboardingModalNavigator',
            path: '/onboarding',
        },
    ],
    index: 1,
});

console.log("rootstate", navigationRef.getRootState()); // <- This is not updated yet and contains the old state
navigation.setParams({report: 123}); // <- Thus this will also use the outdated state

Copy link

melvin-bot bot commented Dec 19, 2024

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@mountiny
Copy link
Contributor Author

@adamgrzybowski @WojtekBoman Seems like the solution we applied for now is just a hot fix but the root cause is else where. Could you take this on to chase down the root cause? Thanks!

@mountiny mountiny removed the DeployBlockerCash This issue or pull request should block deployment label Dec 19, 2024
@mountiny
Copy link
Contributor Author

PR being CPed, will be validated on the checklist

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Dec 23, 2024
@melvin-bot melvin-bot bot changed the title [$500] Onboarding flow is not showing upon first sign in [HOLD for payment 2024-12-30] [$500] Onboarding flow is not showing upon first sign in Dec 23, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Dec 23, 2024
Copy link

melvin-bot bot commented Dec 23, 2024

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

Copy link

melvin-bot bot commented Dec 23, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.77-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 2024-12-30. 🎊

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

Copy link

melvin-bot bot commented Dec 23, 2024

@s77rt @bfitzexpensify @s77rt 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]

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Dec 26, 2024
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-12-30] [$500] Onboarding flow is not showing upon first sign in [HOLD for payment 2025-01-02] [HOLD for payment 2024-12-30] [$500] Onboarding flow is not showing upon first sign in Dec 26, 2024
Copy link

melvin-bot bot commented Dec 26, 2024

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

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

Copy link

melvin-bot bot commented Dec 26, 2024

@s77rt @bfitzexpensify @s77rt 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]

@s77rt
Copy link
Contributor

s77rt commented Dec 28, 2024

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: Migrate E/App to use PlatformStackNavigation #49937 (unknown exact cause but it's very likely that the bug is caused by this PR for switching to PlatformStackNavigation)

  • [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: I don't think this is required here (QA test should pretty much cover this)

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

    Bug requires regression test: No, a test already exists https://expensify.testrail.io/index.php?/cases/view/2990391

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 👎

@bfitzexpensify
Copy link
Contributor

Payment summary:

$500 paid to @nkdengineer for contributor work ✅
$500 to be paid to @s77rt for C+ work

@JmillsExpensify
Copy link

$500 approved for @s77rt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

10 participants