Repository navigation
Add isLoading guard to onboarding pages to prevent duplicate tasks - #89991
Conversation
…ation When clicking Continue multiple times during onboarding, each click fires completeOnboarding with fresh optimistic task IDs, creating duplicate tasks in Concierge. Add isLoading state to BaseOnboardingPersonalDetails, BaseOnboardingPurpose, and BaseOnboardingWorkspaceOptional, matching the existing pattern in BaseOnboardingInterestedFeatures. Co-authored-by: Linh Vo <linhvovan29546@users.noreply.github.com>
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@MelvinBot Please recheck this change to ensure it matches |
|
@MelvinBot Also please resolve conflict |
Match the pattern from BaseOnboardingInterestedFeatures: - Make completeOnboarding calls async with await - Add try/catch/finally to reset isLoading after completion - Add Log.warn for error cases Co-authored-by: Linh Vo <linhvovan29546@users.noreply.github.com>
|
Updated all three files to match the
Changes per file:
|
…icateTaskGuard Co-authored-by: Linh Vo <linhvovan29546@users.noreply.github.com> # Conflicts: # src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx # src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx # src/pages/OnboardingWorkspaceOptional/BaseOnboardingWorkspaceOptional.tsx
|
Resolved merge conflicts with main. The conflicts were in all three onboarding files where main replaced |
Replace try/catch/finally with try/catch, placing setIsLoading(false) in both the success path and catch block. React Compiler cannot handle TryStatement with a finalizer clause. Co-authored-by: Linh Vo <linhvovan29546@users.noreply.github.com>
|
Fixed the failing React Compiler Compliance check: replaced |
|
@MelvinBot Resolve conflict and mark PR as "Ready for review" |
Resolve conflicts: keep async/await + try/catch pattern from PR, adopt main's removal of betas parameter from onboarding calls. Co-authored-by: Linh Vo <linhvovan29546@users.noreply.github.com>
|
@linhvovan29546 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
Resolved merge conflicts and marked as ready for review. Conflicts resolved in 3 files — kept the async/await + try/catch pattern from this PR, adopted main's removal of the
|
|
MelvinBot has made 5 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR. Next steps: A human should review the recent commits and resolve the conflicting CI errors manually. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ddef3b135b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| return; | ||
| } | ||
|
|
||
| setIsLoading(true); |
There was a problem hiding this comment.
Clear loading state when purpose is unset before submit
handleSubmit now sets isLoading to true before calling completeOnboarding, but completeOnboarding immediately returns when onboardingPurposeSelected is falsy. In that state (which can happen if the page is reached via direct navigation/rehydration without a selected purpose), the loading flag is never reset, so the form stays stuck in loading and Continue cannot be pressed again without a reload.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@MelvinBot Please address this. I think we can move setIsLoading to completeOnboarding.
There was a problem hiding this comment.
Done — moved setIsLoading(true) into the completeOnboarding callback (after the guards), matching the existing pattern in BaseOnboardingWorkspaceOptional. Also added isLoading to the guard and dependency array. The track onboarding path in handleSubmit keeps its own setIsLoading(true) since it does not go through this callback.
Moves setIsLoading(true) from handleSubmit into the completeOnboarding useCallback, after the guard checks. This prevents isLoading from being set when completeOnboarding returns early (e.g. when onboardingPurposeSelected is falsy), which would leave the form stuck in a loading state. Matches the existing pattern in BaseOnboardingWorkspaceOptional. Co-authored-by: Linh Vo <linhvovan29546@users.noreply.github.com>
@MelvinBot I’ve verified these separately, so you can mark the checkboxes as completed. |
|
@MelvinBot Please make the PR ready for review |
|
🤖 This PR is now marked Ready for review. |
| ); | ||
| setIsLoading(false); | ||
| } catch (error) { | ||
| Log.warn('[BaseOnboardingPersonalDetails] Error completing onboarding', {error}); |
There was a problem hiding this comment.
❌ CONSISTENCY-3 (docs)
setIsLoading(false) is duplicated in both the try and catch blocks. This can be consolidated using a finally block to avoid duplication and ensure the loading state is always reset regardless of the outcome.
try {
await completeOnboardingReport({...});
setOnboardingAdminsChatReportID();
setOnboardingPolicyID();
navigateAfterOnboardingWithMicrotaskQueue(...);
} catch (error) {
Log.warn('[BaseOnboardingPersonalDetails] Error completing onboarding', {error});
} finally {
setIsLoading(false);
}Reviewed at: 4be7927 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
|
@linhvovan29546, what is going on here? The issue does not have a C+ reviewer or an Expensify employee assigned, and the proposal was never approved by an Expensify employee |
@Gonals Hmm, I’m not sure I understand your question. The process is that a C+ is assigned to the issue. If the C+ agrees with Melvin’s proposal, then Melvin can open the PR. |
Can you point at the documentation indicating so? It may be obsolete or a miscommunication, as the process should be the same regardless of whether the proposal comes from a contributor or Melvin, and final approval should be given by an employee before the PR is created. |
Thanks! We have to update that 😅 We'll go with that approach for this one, since it is our fault the documentation is not up-to-date. Let's resolve conflicts here :) |
|
@MelvinBot Please merge the main branch and resolve conflict |
Resolve conflict in BaseOnboardingPersonalDetails.tsx: keep the isLoading guard/try-catch added by this PR while adopting main's archivedReportsIdSet -> archivedReportsIDSet rename.
|
🤖 Merged There was one conflict, in Resolution: kept this PR's The PR now reports as
|
|
Let me test the changes in this PR again. |
|
@MelvinBot please change your Author Checklist to this: PR Author Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2026-06-03.at.16.23.28.movAndroid: mWeb ChromeScreen.Recording.2026-06-03.at.16.34.09.moviOS: HybridAppScreen.Recording.2026-06-03.at.16.34.09.moviOS: mWeb SafariScreen.Recording.2026-06-03.at.16.23.28.movMacOS: Chrome / SafariScreen.Recording.2026-06-03.at.16.22.35.mov |
|
🤖 Updated the PR description's PR Author Checklist to the version you provided, and replaced the Screenshots/Videos section with your recordings (Android HybridApp, Android mWeb Chrome, iOS HybridApp, iOS mWeb Safari, MacOS). Everything above the checklist (Explanation, Fixed Issues, Tests, Offline tests, QA Steps) was left byte-for-byte unchanged, and I kept the existing AI Tests results block at the end. Let me know if you'd like that AI Tests block removed. |
|
🚧 @Gonals has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/Gonals in version: 9.4.17-0 🚀
Bundle Size Analysis (Sentry): |
|
🤖 No help site changes required. This PR is an internal bug fix and does not change any user-facing feature, label, setting, or documented workflow. What it does: Adds an Why no docs update: The help site articles under Because no changes are required, I have not created a draft help site PR. @linhvovan29546, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR (Note: no help site PR was created since no documentation changes are required for this internal bug fix. If you believe a docs update is warranted, let me know and I'll create one.) |
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.4.17-3 🚀
|
1 similar comment
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.4.17-3 🚀
|
Explanation of Change
During onboarding, clicking "Continue" multiple times (after FormProvider's 1-second debounce window) fires
completeOnboardingrepeatedly, and each call generates fresh optimistic task IDs viaprepareOnboardingOnyxData— producing duplicate tasks in Concierge.This adds an
isLoadingstate guard to the three onboarding pages that callcompleteOnboardingwithout one:BaseOnboardingPersonalDetails— addsisLoadingstate and passes it toFormProviderBaseOnboardingPurpose— addsisLoadingstate to guard theonPresshandlersBaseOnboardingWorkspaceOptional— addsisLoadingstate to guard bothcompleteOnboardingandcreateWorkspaceAndCompleteOnboarding, and passes it to the Skip and Create Workspace buttonsThis matches the existing pattern in
BaseOnboardingInterestedFeatures, which already has this guard.Fixed Issues
$ #89904
PROPOSAL: #89904 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)Avatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: HybridApp
Screen.Recording.2026-06-03.at.16.23.28.mov
Android: mWeb Chrome
Screen.Recording.2026-06-03.at.16.34.09.mov
iOS: HybridApp
Screen.Recording.2026-06-03.at.16.34.09.mov
iOS: mWeb Safari
Screen.Recording.2026-06-03.at.16.23.28.mov
MacOS: Chrome / Safari
Screen.Recording.2026-06-03.at.16.22.35.mov
AI Tests