@@ -22,6 +22,7 @@ import useReportScrollManager from '@hooks/useReportScrollManager';
2222import useReportTransactionsCollection from '@hooks/useReportTransactionsCollection' ;
2323import useResponsiveLayoutOnWideRHP from '@hooks/useResponsiveLayoutOnWideRHP' ;
2424import useScrollToEndOnNewMessageReceived from '@hooks/useScrollToEndOnNewMessageReceived' ;
25+ import useStableReportForReportActionItem from '@hooks/useStableReportForReportActionItem' ;
2526import useThemeStyles from '@hooks/useThemeStyles' ;
2627import useWindowDimensions from '@hooks/useWindowDimensions' ;
2728import { isConsecutiveChronosAutomaticTimerAction } from '@libs/ChronosUtils' ;
@@ -51,6 +52,7 @@ import Visibility from '@libs/Visibility';
5152import isSearchTopmostFullScreenRoute from '@navigation/helpers/isSearchTopmostFullScreenRoute' ;
5253import FloatingMessageCounter from '@pages/inbox/report/FloatingMessageCounter' ;
5354import getInitialNumToRender from '@pages/inbox/report/getInitialNumReportActionsToRender' ;
55+ import ReportActionIndexContext from '@pages/inbox/report/ReportActionIndexContext' ;
5456import ReportActionsListItemRenderer from '@pages/inbox/report/ReportActionsListItemRenderer' ;
5557import { getUnreadMarkerReportAction } from '@pages/inbox/report/shouldDisplayNewMarkerOnReportAction' ;
5658import useReportUnreadMessageScrollTracking from '@pages/inbox/report/useReportUnreadMessageScrollTracking' ;
@@ -99,6 +101,8 @@ function MoneyRequestReportActionsList({onLayout}: MoneyRequestReportListProps)
99101 // Self-subscribe to report, policy, metadata, actions, transactions
100102 // report is guaranteed to exist — callers only render this component when report is loaded
101103 const [ report ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ reportIDFromRoute } ` ) as unknown as [ OnyxTypes . Report ] ;
104+ // Stable reference of `report` for action items
105+ const reportStable = useStableReportForReportActionItem ( report ) ;
102106 const [ policy ] = useOnyx ( `${ ONYXKEYS . COLLECTION . POLICY } ${ getNonEmptyStringOnyxID ( report ?. policyID ) } ` ) ;
103107 const [ reportLoadingState ] = useOnyx ( `${ ONYXKEYS . COLLECTION . RAM_ONLY_REPORT_LOADING_STATE } ${ reportIDFromRoute } ` ) ;
104108 const [ reportPaginationState ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT_PAGINATION_STATE } ${ reportIDFromRoute } ` ) ;
@@ -559,34 +563,35 @@ function MoneyRequestReportActionsList({onLayout}: MoneyRequestReportListProps)
559563 ! isConsecutiveChronosAutomaticTimerAction ( visibleReportActions , index , chatIncludesChronosWithID ( reportAction ?. reportID ) , isOffline ) &&
560564 hasNextActionMadeBySameActor ( visibleReportActions , index , isOffline ) ;
561565
562- const originalReportID = getOriginalReportID ( report ?. reportID , reportAction , reportActionsObject ) ;
566+ const originalReportID = getOriginalReportID ( reportStable ?. reportID , reportAction , reportActionsObject ) ;
563567
564568 return (
565- < ReportActionsListItemRenderer
566- reportAction = { reportAction }
567- parentReportAction = { parentReportAction }
568- parentReportActionForTransactionThread = { EmptyParentReportActionForTransactionThread }
569- index = { index }
570- report = { report }
571- transactionThreadReport = { transactionThreadReport }
572- displayAsGroup = { displayAsGroup }
573- shouldDisplayNewMarker = { reportAction . reportActionID === unreadMarkerReportActionID }
574- shouldDisplayReplyDivider = { visibleReportActions . length > 1 }
575- isFirstVisibleReportAction = { firstVisibleReportActionID === reportAction . reportActionID }
576- shouldHideThreadDividerLine
577- linkedReportActionID = { linkedReportActionID }
578- personalDetails = { personalDetails }
579- originalReportID = { originalReportID }
580- isReportArchived = { isReportArchived }
581- isHarvestCreatedExpenseReport = { shouldShowHarvestCreatedAction }
582- />
569+ < ReportActionIndexContext . Provider value = { index } >
570+ < ReportActionsListItemRenderer
571+ reportAction = { reportAction }
572+ parentReportAction = { parentReportAction }
573+ parentReportActionForTransactionThread = { EmptyParentReportActionForTransactionThread }
574+ report = { reportStable }
575+ transactionThreadReport = { transactionThreadReport }
576+ displayAsGroup = { displayAsGroup }
577+ shouldDisplayNewMarker = { reportAction . reportActionID === unreadMarkerReportActionID }
578+ shouldDisplayReplyDivider = { visibleReportActions . length > 1 }
579+ isFirstVisibleReportAction = { firstVisibleReportActionID === reportAction . reportActionID }
580+ shouldHideThreadDividerLine
581+ linkedReportActionID = { linkedReportActionID }
582+ personalDetails = { personalDetails }
583+ originalReportID = { originalReportID }
584+ isReportArchived = { isReportArchived }
585+ isHarvestCreatedExpenseReport = { shouldShowHarvestCreatedAction }
586+ />
587+ </ ReportActionIndexContext . Provider >
583588 ) ;
584589 } ,
585590 [
586591 visibleReportActions ,
587592 reportActionsObject ,
588593 parentReportAction ,
589- report ,
594+ reportStable ,
590595 isOffline ,
591596 transactionThreadReport ,
592597 unreadMarkerReportActionID ,
0 commit comments