@@ -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,7 @@ 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+ const reportStable = useStableReportForReportActionItem ( report ) ;
102105 const [ policy ] = useOnyx ( `${ ONYXKEYS . COLLECTION . POLICY } ${ getNonEmptyStringOnyxID ( report ?. policyID ) } ` ) ;
103106 const [ reportLoadingState ] = useOnyx ( `${ ONYXKEYS . COLLECTION . RAM_ONLY_REPORT_LOADING_STATE } ${ reportIDFromRoute } ` ) ;
104107 const [ reportPaginationState ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT_PAGINATION_STATE } ${ reportIDFromRoute } ` ) ;
@@ -559,34 +562,35 @@ function MoneyRequestReportActionsList({onLayout}: MoneyRequestReportListProps)
559562 ! isConsecutiveChronosAutomaticTimerAction ( visibleReportActions , index , chatIncludesChronosWithID ( reportAction ?. reportID ) , isOffline ) &&
560563 hasNextActionMadeBySameActor ( visibleReportActions , index , isOffline ) ;
561564
562- const originalReportID = getOriginalReportID ( report ?. reportID , reportAction , reportActionsObject ) ;
565+ const originalReportID = getOriginalReportID ( reportStable ?. reportID , reportAction , reportActionsObject ) ;
563566
564567 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- />
568+ < ReportActionIndexContext . Provider value = { index } >
569+ < ReportActionsListItemRenderer
570+ reportAction = { reportAction }
571+ parentReportAction = { parentReportAction }
572+ parentReportActionForTransactionThread = { EmptyParentReportActionForTransactionThread }
573+ report = { reportStable }
574+ transactionThreadReport = { transactionThreadReport }
575+ displayAsGroup = { displayAsGroup }
576+ shouldDisplayNewMarker = { reportAction . reportActionID === unreadMarkerReportActionID }
577+ shouldDisplayReplyDivider = { visibleReportActions . length > 1 }
578+ isFirstVisibleReportAction = { firstVisibleReportActionID === reportAction . reportActionID }
579+ shouldHideThreadDividerLine
580+ linkedReportActionID = { linkedReportActionID }
581+ personalDetails = { personalDetails }
582+ originalReportID = { originalReportID }
583+ isReportArchived = { isReportArchived }
584+ isHarvestCreatedExpenseReport = { shouldShowHarvestCreatedAction }
585+ />
586+ </ ReportActionIndexContext . Provider >
583587 ) ;
584588 } ,
585589 [
586590 visibleReportActions ,
587591 reportActionsObject ,
588592 parentReportAction ,
589- report ,
593+ reportStable ,
590594 isOffline ,
591595 transactionThreadReport ,
592596 unreadMarkerReportActionID ,
0 commit comments