@@ -323,7 +323,7 @@ describe('actions/Report', () => {
323323
324324 return waitForBatchedUpdates ( )
325325 . then ( ( ) => {
326- Report . clearCreateChatError ( REPORT , CONCIERGE_REPORT_ID , { choice : CONST . ONBOARDING_CHOICES . MANAGE_TEAM } , TEST_USER_ACCOUNT_ID , undefined ) ;
326+ Report . clearCreateChatError ( REPORT , CONCIERGE_REPORT_ID , { choice : CONST . ONBOARDING_CHOICES . MANAGE_TEAM } , TEST_USER_ACCOUNT_ID , undefined , false ) ;
327327 return waitForBatchedUpdates ( ) ;
328328 } )
329329 . then (
@@ -356,7 +356,7 @@ describe('actions/Report', () => {
356356
357357 return waitForBatchedUpdates ( )
358358 . then ( ( ) => {
359- Report . clearCreateChatError ( REPORT , CONCIERGE_REPORT_ID , INTRO_SELECTED , TEST_USER_ACCOUNT_ID , undefined ) ;
359+ Report . clearCreateChatError ( REPORT , CONCIERGE_REPORT_ID , INTRO_SELECTED , TEST_USER_ACCOUNT_ID , undefined , false ) ;
360360 return waitForBatchedUpdates ( ) ;
361361 } )
362362 . then (
@@ -388,7 +388,7 @@ describe('actions/Report', () => {
388388
389389 return waitForBatchedUpdates ( )
390390 . then ( ( ) => {
391- Report . clearCreateChatError ( REPORT , CONCIERGE_REPORT_ID , INTRO_SELECTED , TEST_USER_ACCOUNT_ID , undefined ) ;
391+ Report . clearCreateChatError ( REPORT , CONCIERGE_REPORT_ID , INTRO_SELECTED , TEST_USER_ACCOUNT_ID , undefined , false ) ;
392392 return waitForBatchedUpdates ( ) ;
393393 } )
394394 . then (
@@ -409,12 +409,14 @@ describe('actions/Report', () => {
409409 ) ;
410410 } ) ;
411411
412- it ( 'clearCreateChatError should forward betas through navigateToConciergeChatAndDeleteReport when deleting optimistic report' , async ( ) => {
412+ it . each < [ string , OnyxTypes . Beta [ ] | undefined ] > ( [
413+ [ 'with betas' , [ CONST . BETAS . ALL ] ] ,
414+ [ 'without betas' , undefined ] ,
415+ ] ) ( 'clearCreateChatError should call openReport when deleting optimistic report %s' , async ( _label , betas ) => {
413416 const TEST_USER_ACCOUNT_ID = 1 ;
414417 const TEST_USER_LOGIN = 'test@user.com' ;
415418 const REPORT : OnyxTypes . Report = { ...createRandomReport ( 1 , undefined ) , errorFields : { createChat : { error : 'error' } } } ;
416419 const INTRO_SELECTED : OnyxTypes . IntroSelected = { choice : CONST . ONBOARDING_CHOICES . MANAGE_TEAM } ;
417- const testBetas = [ CONST . BETAS . ALL ] ;
418420
419421 await TestHelper . signInWithTestUser ( TEST_USER_ACCOUNT_ID , TEST_USER_LOGIN ) ;
420422 await TestHelper . setPersonalDetails ( TEST_USER_LOGIN , TEST_USER_ACCOUNT_ID ) ;
@@ -429,7 +431,7 @@ describe('actions/Report', () => {
429431 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT_METADATA } ${ REPORT . reportID } ` , { isOptimisticReport : true } ) ;
430432 await waitForBatchedUpdates ( ) ;
431433
432- Report . clearCreateChatError ( REPORT , undefined , INTRO_SELECTED , TEST_USER_ACCOUNT_ID , testBetas ) ;
434+ Report . clearCreateChatError ( REPORT , undefined , INTRO_SELECTED , TEST_USER_ACCOUNT_ID , betas , false ) ;
433435 await waitForBatchedUpdates ( ) ;
434436
435437 TestHelper . expectAPICommandToHaveBeenCalled ( WRITE_COMMANDS . OPEN_REPORT , 1 ) ;
@@ -6476,7 +6478,7 @@ describe('actions/Report', () => {
64766478 } ) ;
64776479
64786480 describe ( 'navigateToAndOpenReportWithAccountIDs' , ( ) => {
6479- it ( 'should create new chat and pass betas to openReport when no existing chat' , async ( ) => {
6481+ it . each ( [ true , false ] ) ( 'should create new chat and call openReport when no existing chat (isSelfTourViewed=%s) ' , async ( isSelfTourViewed ) => {
64806482 const TEST_USER_ACCOUNT_ID = 1 ;
64816483 const TEST_USER_LOGIN = 'test@user.com' ;
64826484 const PARTICIPANT_ACCOUNT_ID = 2 ;
@@ -6486,7 +6488,7 @@ describe('actions/Report', () => {
64866488
64876489 const testIntroSelected : OnyxTypes . IntroSelected = { choice : CONST . ONBOARDING_CHOICES . ADMIN } ;
64886490
6489- Report . navigateToAndOpenReportWithAccountIDs ( [ PARTICIPANT_ACCOUNT_ID ] , TEST_USER_ACCOUNT_ID , testIntroSelected , undefined ) ;
6491+ Report . navigateToAndOpenReportWithAccountIDs ( [ PARTICIPANT_ACCOUNT_ID ] , TEST_USER_ACCOUNT_ID , testIntroSelected , isSelfTourViewed , undefined ) ;
64906492 await waitForBatchedUpdates ( ) ;
64916493
64926494 TestHelper . expectAPICommandToHaveBeenCalled ( WRITE_COMMANDS . OPEN_REPORT , 1 ) ;
@@ -6513,7 +6515,7 @@ describe('actions/Report', () => {
65136515
65146516 const testIntroSelected : OnyxTypes . IntroSelected = { choice : CONST . ONBOARDING_CHOICES . ADMIN } ;
65156517
6516- Report . navigateToAndOpenReportWithAccountIDs ( [ PARTICIPANT_ACCOUNT_ID ] , TEST_USER_ACCOUNT_ID , testIntroSelected , undefined ) ;
6518+ Report . navigateToAndOpenReportWithAccountIDs ( [ PARTICIPANT_ACCOUNT_ID ] , TEST_USER_ACCOUNT_ID , testIntroSelected , false , undefined ) ;
65176519 await waitForBatchedUpdates ( ) ;
65186520
65196521 TestHelper . expectAPICommandToHaveBeenCalled ( WRITE_COMMANDS . OPEN_REPORT , 0 ) ;
@@ -6579,6 +6581,29 @@ describe('actions/Report', () => {
65796581 expect ( result ?. successData ) . toBeDefined ( ) ;
65806582 expect ( result ?. failureData ) . toBeDefined ( ) ;
65816583 } ) ;
6584+
6585+ it . each < [ boolean , string ] > ( [
6586+ [ true , 'should be defined' ] ,
6587+ [ false , 'should be undefined' ] ,
6588+ ] ) ( 'viewTour completedTaskReportActionID when isSelfTourViewed=%s %s' , async ( isSelfTourViewed ) => {
6589+ await setupUserWithConciergeChat ( ) ;
6590+ await Onyx . merge ( ONYXKEYS . NVP_ONBOARDING , { hasCompletedGuidedSetupFlow : false } ) ;
6591+ await waitForBatchedUpdates ( ) ;
6592+
6593+ const introSelected : OnyxTypes . IntroSelected = { choice : CONST . ONBOARDING_CHOICES . SUBMIT , isInviteOnboardingComplete : false } ;
6594+ const result = Report . getGuidedSetupDataForOpenReport ( introSelected , undefined , isSelfTourViewed ) ;
6595+
6596+ expect ( result ) . toBeDefined ( ) ;
6597+ const guidedSetupData = JSON . parse ( result ?. guidedSetupData ?? '[]' ) as Array < { type : string ; task ?: string ; completedTaskReportActionID ?: string } > ;
6598+ const viewTourTask = guidedSetupData . find ( ( item ) => item . type === 'task' && item . task === CONST . ONBOARDING_TASK_TYPE . VIEW_TOUR ) ;
6599+ expect ( viewTourTask ) . toBeDefined ( ) ;
6600+
6601+ if ( isSelfTourViewed ) {
6602+ expect ( viewTourTask ?. completedTaskReportActionID ) . toBeDefined ( ) ;
6603+ } else {
6604+ expect ( viewTourTask ?. completedTaskReportActionID ) . toBeUndefined ( ) ;
6605+ }
6606+ } ) ;
65826607 } ) ;
65836608
65846609 describe ( 'createTransactionThreadReport' , ( ) => {
0 commit comments