File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,11 +30,20 @@ function SidebarLinksData({insets}: SidebarLinksDataProps) {
3030 currentReportIDRef . current = currentReportID ;
3131 const isActiveReport = useCallback ( ( reportID : string ) : boolean => currentReportIDRef . current === reportID , [ ] ) ;
3232
33- // IMPORTANT: Always end the telemetry navigation span for the Inbox tab when the screen gains focus.
34- // This must handle both the initial mount and all subsequent Inbox tab visits,
35- // as onLayout does not fire when navigating back to an already-mounted screen.
33+ // Guards against ending the span before the first layout has completed.
34+ const hasHadFirstLayout = useRef ( false ) ;
35+ const onLayout = useCallback ( ( ) => {
36+ hasHadFirstLayout . current = true ;
37+ endSpan ( CONST . TELEMETRY . SPAN_NAVIGATE_TO_INBOX_TAB ) ;
38+ } , [ ] ) ;
39+
40+ // On re-visits, react-freeze serves the cached layout — onLayout never fires.
41+ // useFocusEffect fires on unfreeze, which is when the screen becomes visible.
3642 useFocusEffect (
3743 useCallback ( ( ) => {
44+ if ( ! hasHadFirstLayout . current ) {
45+ return ;
46+ }
3847 endSpan ( CONST . TELEMETRY . SPAN_NAVIGATE_TO_INBOX_TAB ) ;
3948 } , [ ] ) ,
4049 ) ;
@@ -45,6 +54,7 @@ function SidebarLinksData({insets}: SidebarLinksDataProps) {
4554 collapsable = { false }
4655 accessibilityLabel = { translate ( 'sidebarScreen.listOfChats' ) }
4756 style = { [ styles . flex1 , styles . h100 ] }
57+ onLayout = { onLayout }
4858 >
4959 < SidebarLinks
5060 // Forwarded props:
You can’t perform that action at this time.
0 commit comments