@@ -23,6 +23,7 @@ import type * as OnyxTypes from '@src/types/onyx';
2323import type { Icon } from '@src/types/onyx/OnyxCommon' ;
2424import type { ReportActions } from '@src/types/onyx/ReportAction' ;
2525import type ReportAction from '@src/types/onyx/ReportAction' ;
26+ import type { OnyxData } from '@src/types/onyx/Request' ;
2627import { isEmptyObject } from '@src/types/utils/EmptyObject' ;
2728import { getMostRecentReportID , navigateToConciergeChatAndDeleteReport , notifyNewAction } from './Report' ;
2829
@@ -87,6 +88,12 @@ Onyx.connect({
8788 } ,
8889} ) ;
8990
91+ let introSelected : OnyxEntry < OnyxTypes . IntroSelected > = { } ;
92+ Onyx . connect ( {
93+ key : ONYXKEYS . NVP_INTRO_SELECTED ,
94+ callback : ( val ) => ( introSelected = val ) ,
95+ } ) ;
96+
9097/**
9198 * Clears out the task info from the store
9299 */
@@ -370,11 +377,11 @@ function getOutstandingChildTask(taskReport: OnyxEntry<OnyxTypes.Report>) {
370377/**
371378 * Complete a task
372379 */
373- function completeTask ( taskReport : OnyxEntry < OnyxTypes . Report > , reportIDFromAction ?: string ) {
380+ function completeTask ( taskReport : OnyxEntry < OnyxTypes . Report > , reportIDFromAction ?: string ) : OnyxData {
374381 const taskReportID = taskReport ?. reportID ?? reportIDFromAction ;
375382
376383 if ( ! taskReportID ) {
377- return ;
384+ return { } ;
378385 }
379386
380387 const message = `marked as complete` ;
@@ -455,6 +462,7 @@ function completeTask(taskReport: OnyxEntry<OnyxTypes.Report>, reportIDFromActio
455462
456463 playSound ( SOUNDS . SUCCESS ) ;
457464 API . write ( WRITE_COMMANDS . COMPLETE_TASK , parameters , { optimisticData, successData, failureData} ) ;
465+ return { optimisticData, successData, failureData} ;
458466}
459467
460468/**
@@ -1266,6 +1274,19 @@ function clearTaskErrors(reportID: string | undefined) {
12661274 } ) ;
12671275}
12681276
1277+ function getFinishOnboardingTaskOnyxData ( taskName : keyof OnyxTypes . IntroSelected ) : OnyxData {
1278+ const taskReportID = introSelected ?. [ taskName ] ;
1279+ if ( taskReportID ) {
1280+ const taskReport = allReports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ taskReportID } ` ] ;
1281+ if ( taskReport ) {
1282+ if ( taskReport . stateNum !== CONST . REPORT . STATE_NUM . APPROVED || taskReport . statusNum !== CONST . REPORT . STATUS_NUM . APPROVED ) {
1283+ return completeTask ( taskReport ) ;
1284+ }
1285+ }
1286+ }
1287+
1288+ return { } ;
1289+ }
12691290function completeTestDriveTask ( ) {
12701291 const onboardingReport = ReportUtils . getChatUsedForOnboarding ( ) ;
12711292 if ( ! onboardingReport ) {
@@ -1312,5 +1333,6 @@ export {
13121333 setNewOptimisticAssignee ,
13131334 getNavigationUrlOnTaskDelete ,
13141335 canActionTask ,
1336+ getFinishOnboardingTaskOnyxData ,
13151337 completeTestDriveTask ,
13161338} ;
0 commit comments