11import { deepEqual } from 'fast-equals' ;
2- import React , { useMemo , useRef } from 'react' ;
2+ import React , { useCallback , useMemo , useRef } from 'react' ;
33import useReportPreviewSenderID from '@components/ReportActionAvatars/useReportPreviewSenderID' ;
44import { useCurrentReportIDState } from '@hooks/useCurrentReportID' ;
55import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails' ;
@@ -12,6 +12,7 @@ import CONST from '@src/CONST';
1212import { getMovedReportID } from '@src/libs/ModifiedExpenseMessage' ;
1313import type { OptionData } from '@src/libs/ReportUtils' ;
1414import ONYXKEYS from '@src/ONYXKEYS' ;
15+ import type { ReportAttributesDerivedValue } from '@src/types/onyx/DerivedValues' ;
1516import type { Icon } from '@src/types/onyx/OnyxCommon' ;
1617import OptionRowLHN from './OptionRowLHN' ;
1718import type { OptionRowLHNDataProps } from './types' ;
@@ -25,9 +26,6 @@ import type {OptionRowLHNDataProps} from './types';
2526function OptionRowLHNData ( {
2627 isOptionFocused = false ,
2728 fullReport,
28- reportAttributes,
29- reportAttributesDerived,
30- oneTransactionThreadReport,
3129 reportNameValuePairs,
3230 reportActions,
3331 personalDetails = { } ,
@@ -53,6 +51,12 @@ function OptionRowLHNData({
5351 const isReportFocused = isOptionFocused && currentReportIDValue === reportID ;
5452 const optionItemRef = useRef < OptionData | undefined > ( undefined ) ;
5553
54+ const reportAttributesSelector = useCallback ( ( data : ReportAttributesDerivedValue | undefined ) => data ?. reports ?. [ reportID ] , [ reportID ] ) ;
55+ const [ reportAttributes ] = useOnyx ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES , { selector : reportAttributesSelector } ) ;
56+
57+ // Look up the one-transaction thread report using the ID from our own attributes.
58+ const [ oneTransactionThreadReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ getNonEmptyStringOnyxID ( reportAttributes ?. oneTransactionThreadReportID ) } ` ) ;
59+
5660 const [ movedFromReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ getMovedReportID ( lastAction , CONST . REPORT . MOVE_TYPE . FROM ) } ` ) ;
5761 const [ movedToReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ getMovedReportID ( lastAction , CONST . REPORT . MOVE_TYPE . TO ) } ` ) ;
5862 const [ conciergeReportID ] = useOnyx ( ONYXKEYS . CONCIERGE_REPORT_ID ) ;
@@ -72,6 +76,13 @@ function OptionRowLHNData({
7276 chatReport : chatReportForIOU ,
7377 } ) ;
7478
79+ const reportAttributesDerived = useMemo ( ( ) => {
80+ if ( ! reportAttributes ) {
81+ return undefined ;
82+ }
83+ return { [ reportID ] : reportAttributes } as ReportAttributesDerivedValue [ 'reports' ] ;
84+ } , [ reportID , reportAttributes ] ) ;
85+
7586 const optionItem = useMemo ( ( ) => {
7687 // Note: ideally we'd have this as a dependent selector in onyx!
7788 const item = SidebarUtils . getOptionData ( {
0 commit comments