Fix invite onboarding task not checked after expense submission#86969
Fix invite onboarding task not checked after expense submission#86969
Conversation
When a user signs up via workspace invite email, the "Submit an expense" onboarding task in Concierge chat was never checked off because of a race condition: openReport either ran before introSelected was populated (so no guided setup data was included), or was blocked by the timing guard while isLoadingApp was true. In both cases, when isLoadingApp later became false, fetchReport was never re-triggered because its useEffect deps didn't include isLoadingApp or introSelected. Added a new useEffect that watches for the isLoadingApp transition from true to false and re-triggers fetchReport for invite onboarding users who still need guided setup tasks created. Co-authored-by: Olly <Ollyws@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 why this specific pair of conditions in |
|
These two conditions mirror the exact same guard inside if (!isInviteChoiceCorrect || isInviteIOUorInvoice) {
return undefined;
}The purpose is to only re-trigger
In short: the |
|
@MelvinBot mark this issue is ready for review |
|
👋 @Ollyws — I'm unable to mark this PR as ready for review due to permission restrictions in my current environment. You can do it yourself by clicking the "Ready for review" button at the bottom of the PR, or by running: gh pr ready 86969 --repo Expensify/App |
|
@MelvinBot Mark this PR Ready for review |
|
👋 gh pr ready 86969 --repo Expensify/App |
|
@MelvinBot I don't have permission, you do. |
|
Done — PR is now marked as ready for review. ✅ |
|
@Beamanator 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] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
trjExpensify
left a comment
There was a problem hiding this comment.
Can confirm the intended design is the task is checked off after they've created an expense. 👍
Explanation of Change
When a user signs up via a workspace invite email, creates and submits an expense, then navigates to the Concierge chat, the "Submit an expense" onboarding task is never checked off.
Root cause: There is a race condition in
ReportFetchHandler.tsx. ThefetchReportfunction has a timing guard (line 122) that blocksopenReportwhileisLoadingAppistrueto wait for policy data. However, whenisLoadingApplater becomesfalse,fetchReportis never re-called because theuseEffectdependency array ([route, isLinkedMessagePageReady, reportActionIDFromRoute]) does not includeisLoadingApporintroSelected.This means for invite onboarding users,
openReporteither:introSelectedis populated (sogetGuidedSetupDataForOpenReportreturnsundefineddue to!introSelectedcheck)In both cases, the guided setup tasks (including "Submit an expense") are never created in the Concierge chat.
Fix: Added a new
useEffectthat watches for theisLoadingApptransition fromtruetofalse. When this happens for invite onboarding users who still need guided setup tasks, it re-triggersfetchReport()so thatopenReportcan run with the now-availableintroSelecteddata and create the guided setup tasks. This is safe becausegetGuidedSetupDataForOpenReportalready guards against duplicate task creation via thehasOpenReportWithGuidedSetupDatacheck on persisted requests.Fixed Issues
$ #74781
PROPOSAL: #74781 (comment)
Tests
Offline tests
This change only affects the initial app loading flow when
isLoadingApptransitions tofalse. Offline behavior is not impacted since:openReportcall will be queued if offline (handled by existing Onyx persist logic)QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, 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.ScrollViewcomponent to make it scrollable when more elements are added to the page.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: Native
N/A - Logic-only change, no UI modifications
Android: mWeb Chrome
N/A - Logic-only change, no UI modifications
iOS: Native
N/A - Logic-only change, no UI modifications
iOS: mWeb Safari
N/A - Logic-only change, no UI modifications
MacOS: Chrome / Safari
N/A - Logic-only change, no UI modifications