@@ -276,6 +276,8 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
276276 const [ isBannerVisible , setIsBannerVisible ] = useState ( true ) ;
277277 const [ scrollPosition , setScrollPosition ] = useState < ScrollPosition > ( { } ) ;
278278
279+ const wasReportAccessibleRef = useRef ( false ) ;
280+
279281 const [ isComposerFocus , setIsComposerFocus ] = useState ( false ) ;
280282 const shouldAdjustScrollView = useMemo ( ( ) => isComposerFocus && ! modal ?. willAlertModalBecomeVisible , [ isComposerFocus , modal ] ) ;
281283 const viewportOffsetTop = useViewportOffsetTop ( shouldAdjustScrollView ) ;
@@ -323,6 +325,14 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
323325 hideEmojiPicker ( true ) ;
324326 } , [ prevIsFocused , isFocused ] ) ;
325327
328+ useEffect ( ( ) => {
329+ if ( ! report ?. reportID ) {
330+ wasReportAccessibleRef . current = false ;
331+ return ;
332+ }
333+ wasReportAccessibleRef . current = true ;
334+ } , [ report ] ) ;
335+
326336 const backTo = route ?. params ?. backTo as string ;
327337 const onBackButtonPress = useCallback ( ( ) => {
328338 if ( backTo === SCREENS . SEARCH . REPORT_RHP ) {
@@ -441,7 +451,7 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
441451 }
442452
443453 // eslint-disable-next-line react-compiler/react-compiler
444- if ( ! firstRenderRef . current && ! reportID && ! isOptimisticDelete && ! reportMetadata ?. isLoadingInitialReportActions && ! userLeavingStatus ) {
454+ if ( ! wasReportAccessibleRef . current && ! firstRenderRef . current && ! reportID && ! isOptimisticDelete && ! reportMetadata ?. isLoadingInitialReportActions && ! userLeavingStatus ) {
445455 // eslint-disable-next-line react-compiler/react-compiler
446456 return true ;
447457 }
0 commit comments