@@ -53,7 +53,6 @@ import {
5353 isExpenseReport ,
5454 isInvoiceReport ,
5555 isIOUReport ,
56- isMoneyRequestReport ,
5756 isTaskReport ,
5857 isUnread ,
5958} from '@libs/ReportUtils' ;
@@ -184,14 +183,9 @@ function ReportActionsList({
184183 const [ tryNewDot ] = useOnyx ( ONYXKEYS . NVP_TRY_NEW_DOT , { canBeMissing : false } ) ;
185184 const isTryNewDotNVPDismissed = ! ! tryNewDot ?. classicRedirect ?. dismissed ;
186185 const [ isScrollToBottomEnabled , setIsScrollToBottomEnabled ] = useState ( false ) ;
186+ const [ shouldScrollToEndAfterLayout , setShouldScrollToEndAfterLayout ] = useState ( false ) ;
187187 const [ actionIdToHighlight , setActionIdToHighlight ] = useState ( '' ) ;
188188
189- const isTransactionThreadReport = useMemo ( ( ) => isTransactionThread ( parentReportAction ) , [ parentReportAction ] ) ;
190- const isMoneyRequestOrInvoiceReport = useMemo ( ( ) => isMoneyRequestReport ( report ) || isInvoiceReport ( report ) , [ report ] ) ;
191- const shouldFocusToTopOnMount = useMemo ( ( ) => isTransactionThreadReport || isMoneyRequestOrInvoiceReport , [ isMoneyRequestOrInvoiceReport , isTransactionThreadReport ] ) ;
192- const topReportAction = sortedVisibleReportActions . at ( - 1 ) ;
193- const [ shouldScrollToEndAfterLayout , setShouldScrollToEndAfterLayout ] = useState ( shouldFocusToTopOnMount ) ;
194-
195189 useEffect ( ( ) => {
196190 const unsubscribe = Visibility . onVisibilityChange ( ( ) => {
197191 setIsVisible ( Visibility . isVisible ( ) ) ;
@@ -348,9 +342,6 @@ function ReportActionsList({
348342 onTrackScrolling : ( event : NativeSyntheticEvent < NativeScrollEvent > ) => {
349343 scrollingVerticalOffset . current = event . nativeEvent . contentOffset . y ;
350344 onScroll ?.( event ) ;
351- if ( shouldScrollToEndAfterLayout ) {
352- setShouldScrollToEndAfterLayout ( false ) ;
353- }
354345 } ,
355346 } ) ;
356347
@@ -400,10 +391,17 @@ function ReportActionsList({
400391 return ;
401392 }
402393
394+ const shouldScrollToEnd =
395+ ( isExpenseReport ( report ) || isTransactionThread ( parentReportAction ) ) && isSearchTopmostFullScreenRoute ( ) && hasNewestReportAction && ! unreadMarkerReportActionID ;
396+
397+ if ( shouldScrollToEnd ) {
398+ setShouldScrollToEndAfterLayout ( true ) ;
399+ }
400+
403401 InteractionManager . runAfterInteractions ( ( ) => {
404402 setIsFloatingMessageCounterVisible ( false ) ;
405403
406- if ( ! shouldScrollToEndAfterLayout ) {
404+ if ( ! shouldScrollToEnd ) {
407405 reportScrollManager . scrollToBottom ( ) ;
408406 }
409407 } ) ;
@@ -721,9 +719,8 @@ function ReportActionsList({
721719 setIsScrollToBottomEnabled ( false ) ;
722720 }
723721 if ( shouldScrollToEndAfterLayout ) {
724- InteractionManager . runAfterInteractions ( ( ) => {
725- reportScrollManager . scrollToEnd ( ) ;
726- } ) ;
722+ reportScrollManager . scrollToEnd ( ) ;
723+ setShouldScrollToEndAfterLayout ( false ) ;
727724 }
728725 } ,
729726 [ isScrollToBottomEnabled , onLayout , reportScrollManager , shouldScrollToEndAfterLayout ] ,
@@ -759,13 +756,6 @@ function ReportActionsList({
759756 return < ReportActionsSkeletonView shouldAnimate = { false } /> ;
760757 } , [ shouldShowSkeleton ] ) ;
761758
762- const renderTopReportAction = ( ) => (
763- < >
764- { ! shouldShowReportRecipientLocalTime && ! hideComposer ? < View style = { [ styles . stickToBottom , styles . appBG , styles . zIndex10 , styles . height4 ] } /> : undefined }
765- < View style = { styles . pt4 } > { renderItem ( { item : topReportAction , index : sortedVisibleReportActions . length - 1 } as ListRenderItemInfo < OnyxTypes . ReportAction > ) } </ View >
766- </ >
767- ) ;
768-
769759 const onStartReached = useCallback ( ( ) => {
770760 if ( ! isSearchTopmostFullScreenRoute ( ) ) {
771761 loadNewerChats ( false ) ;
@@ -790,7 +780,6 @@ function ReportActionsList({
790780 style = { [ styles . flex1 , ! shouldShowReportRecipientLocalTime && ! hideComposer ? styles . pb4 : { } ] }
791781 fsClass = { reportActionsListFSClass }
792782 >
793- { shouldScrollToEndAfterLayout && topReportAction ? renderTopReportAction ( ) : undefined }
794783 < InvertedFlatList
795784 accessibilityLabel = { translate ( 'sidebarScreen.listOfChatMessages' ) }
796785 ref = { reportScrollManager . ref }
@@ -799,11 +788,7 @@ function ReportActionsList({
799788 data = { sortedVisibleReportActions }
800789 renderItem = { renderItem }
801790 renderScrollComponent = { renderActionSheetAwareScrollView }
802- contentContainerStyle = { [
803- styles . chatContentScrollView ,
804- shouldScrollToEndAfterLayout ? styles . opacity0 : styles . opacity1 ,
805- shouldFocusToTopOnMount ? styles . justifyContentEnd : undefined ,
806- ] }
791+ contentContainerStyle = { styles . chatContentScrollView }
807792 keyExtractor = { keyExtractor }
808793 initialNumToRender = { initialNumToRender }
809794 onEndReached = { onEndReached }
0 commit comments