Bug Description
In AppRoutes.jsx, the OnboardingRoute guard contains this condition to redirect away from onboarding:
if (userData?.onboardingStatus === "complete" || !isOnboarding || (userData && userData.onboardingStatus !== "incomplete"))
The third clause (userData && userData.onboardingStatus !== "incomplete") is triggered whenever userData exists and onboardingStatus is anything other than "incomplete" — including undefined. Since Firestore userData loads asynchronously after authentication, there is a brief window where userData is populated (the document exists) but onboardingStatus hasn't been written yet (e.g. a race condition during first-time account creation in Onboarding.jsx's runTransaction). During this window, userData.onboardingStatus is undefined, which is !== "incomplete", so the third clause fires and redirects the user away from /onboarding before they can complete it.
Root Cause:
The third condition is redundant with the first (onboardingStatus === "complete") but additionally catches the undefined case, which is a legitimate intermediate state during first-time onboarding. The loading check above only guards against auth loading, not Firestore document loading.
Steps to Reproduce:
- Create a new GitHub account and log in for the first time.
- During the brief window between user document creation and onboardingStatus being set to "incomplete", the route guard evaluates userData.onboardingStatus as undefined.
- The third clause fires and redirects the user to /dashboard before onboarding completes.
Expected Behavior:
OnboardingRoute should only redirect away from /onboarding when onboardingStatus is explicitly "complete", not when it is undefined or any other intermediate value. Users with an incomplete or pending onboarding document should always be allowed to stay on /onboarding.
Affected File(s):
- src/routes/AppRoutes.jsx (OnboardingRoute component)
Suggested Fix:
Simplify the redirect condition to only check the two explicit cases: userData?.onboardingStatus === "complete" || (userData && !isOnboarding), removing the third redundant clause that incorrectly matches undefined onboardingStatus values.
Bug Description
In AppRoutes.jsx, the OnboardingRoute guard contains this condition to redirect away from onboarding:
if (userData?.onboardingStatus === "complete" || !isOnboarding || (userData && userData.onboardingStatus !== "incomplete"))
The third clause (userData && userData.onboardingStatus !== "incomplete") is triggered whenever userData exists and onboardingStatus is anything other than "incomplete" — including undefined. Since Firestore userData loads asynchronously after authentication, there is a brief window where userData is populated (the document exists) but onboardingStatus hasn't been written yet (e.g. a race condition during first-time account creation in Onboarding.jsx's runTransaction). During this window, userData.onboardingStatus is undefined, which is !== "incomplete", so the third clause fires and redirects the user away from /onboarding before they can complete it.
Root Cause:
The third condition is redundant with the first (onboardingStatus === "complete") but additionally catches the undefined case, which is a legitimate intermediate state during first-time onboarding. The loading check above only guards against auth loading, not Firestore document loading.
Steps to Reproduce:
Expected Behavior:
OnboardingRoute should only redirect away from /onboarding when onboardingStatus is explicitly "complete", not when it is undefined or any other intermediate value. Users with an incomplete or pending onboarding document should always be allowed to stay on /onboarding.
Affected File(s):
Suggested Fix:
Simplify the redirect condition to only check the two explicit cases: userData?.onboardingStatus === "complete" || (userData && !isOnboarding), removing the third redundant clause that incorrectly matches undefined onboardingStatus values.