@@ -114,7 +114,7 @@ import {
114114 buildOptimisticSelfDMReport ,
115115 buildOptimisticUnreportedTransactionAction ,
116116 canUserPerformWriteAction as canUserPerformWriteActionReportUtils ,
117- findLastAccessedReport ,
117+ findLastAccessedReportWithoutView ,
118118 findSelfDMReportID ,
119119 formatReportLastMessageText ,
120120 generateReportID ,
@@ -3412,7 +3412,7 @@ function openReportFromDeepLink(
34123412 // Navigate to the report after sign-in/sign-up.
34133413 InteractionManager . runAfterInteractions ( ( ) => {
34143414 waitForUserSignIn ( ) . then ( ( ) => {
3415- const connection = Onyx . connect ( {
3415+ const connection = Onyx . connectWithoutView ( {
34163416 key : ONYXKEYS . NVP_ONBOARDING ,
34173417 callback : ( val ) => {
34183418 if ( ! val && ! isAnonymousUser ( ) ) {
@@ -3458,7 +3458,7 @@ function openReportFromDeepLink(
34583458 const report = allReports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ reportID } ` ] ;
34593459 // If the report does not exist, navigate to the last accessed report or Concierge chat
34603460 if ( reportID && ! report ) {
3461- const lastAccessedReportID = findLastAccessedReport ( false , shouldOpenOnAdminRoom ( ) , undefined , reportID ) ?. reportID ;
3461+ const lastAccessedReportID = findLastAccessedReportWithoutView ( false , shouldOpenOnAdminRoom ( ) , undefined , reportID ) ?. reportID ;
34623462 if ( lastAccessedReportID ) {
34633463 const lastAccessedReportRoute = ROUTES . REPORT_WITH_ID . getRoute ( lastAccessedReportID ) ;
34643464 Navigation . navigate ( lastAccessedReportRoute ) ;
@@ -3504,9 +3504,7 @@ function getCurrentUserEmail(): string | undefined {
35043504 return currentUserEmail ;
35053505}
35063506
3507- function navigateToMostRecentReport ( currentReport : OnyxEntry < Report > ) {
3508- const lastAccessedReportID = findLastAccessedReport ( false , false , undefined , currentReport ?. reportID ) ?. reportID ;
3509-
3507+ function navigateToMostRecentReport ( currentReport : OnyxEntry < Report > , lastAccessedReportID : string | undefined ) {
35103508 if ( lastAccessedReportID ) {
35113509 const lastAccessedReportRoute = ROUTES . REPORT_WITH_ID . getRoute ( lastAccessedReportID ) ;
35123510 Navigation . goBack ( lastAccessedReportRoute ) ;
@@ -3522,8 +3520,7 @@ function navigateToMostRecentReport(currentReport: OnyxEntry<Report>) {
35223520 }
35233521}
35243522
3525- function getMostRecentReportID ( currentReport : OnyxEntry < Report > ) {
3526- const lastAccessedReportID = findLastAccessedReport ( false , false , undefined , currentReport ?. reportID ) ?. reportID ;
3523+ function getMostRecentReportID ( lastAccessedReportID : string | undefined ) {
35273524 return lastAccessedReportID ?? conciergeReportID ;
35283525}
35293526
@@ -3540,7 +3537,7 @@ function joinRoom(report: OnyxEntry<Report>) {
35403537 ) ;
35413538}
35423539
3543- function leaveGroupChat ( reportID : string ) {
3540+ function leaveGroupChat ( reportID : string , lastAccessedReportID : string | undefined ) {
35443541 const report = allReports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ reportID } ` ] ;
35453542 if ( ! report ) {
35463543 Log . warn ( 'Attempting to leave Group Chat that does not existing locally' ) ;
@@ -3592,12 +3589,12 @@ function leaveGroupChat(reportID: string) {
35923589 } ,
35933590 ] ;
35943591
3595- navigateToMostRecentReport ( report ) ;
3592+ navigateToMostRecentReport ( report , lastAccessedReportID ) ;
35963593 API . write ( WRITE_COMMANDS . LEAVE_GROUP_CHAT , { reportID} , { optimisticData, successData, failureData} ) ;
35973594}
35983595
35993596/** Leave a report by setting the state to submitted and closed */
3600- function leaveRoom ( reportID : string , isWorkspaceMemberLeavingWorkspaceRoom = false ) {
3597+ function leaveRoom ( reportID : string , lastAccessedReportID : string | undefined , isWorkspaceMemberLeavingWorkspaceRoom = false ) {
36013598 const report = allReports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ reportID } ` ] ;
36023599
36033600 if ( ! report ) {
@@ -3704,7 +3701,7 @@ function leaveRoom(reportID: string, isWorkspaceMemberLeavingWorkspaceRoom = fal
37043701 return ;
37053702 }
37063703 // In other cases, the report is deleted and we should move the user to another report.
3707- navigateToMostRecentReport ( report ) ;
3704+ navigateToMostRecentReport ( report , lastAccessedReportID ) ;
37083705}
37093706
37103707function buildInviteToRoomOnyxData ( reportID : string , inviteeEmailsToAccountIDs : InvitedEmailsToAccountIDs , formatPhoneNumber : LocaleContextProps [ 'formatPhoneNumber' ] ) {
0 commit comments