@@ -3,7 +3,7 @@ import {View} from 'react-native';
33import type { OnyxCollection , OnyxEntry } from 'react-native-onyx' ;
44import OfflineWithFeedback from '@components/OfflineWithFeedback' ;
55import useNetwork from '@hooks/useNetwork' ;
6- import useReportIsArchived from '@hooks/useReportIsArchived ' ;
6+ import useOnyx from '@hooks/useOnyx ' ;
77import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
88import useThemeStyles from '@hooks/useThemeStyles' ;
99import onyxSubscribe from '@libs/onyxSubscribe' ;
@@ -14,6 +14,7 @@ import {
1414 canUserPerformWriteAction as canUserPerformWriteActionReportUtils ,
1515 getAllAncestorReportActionIDs ,
1616 getAllAncestorReportActions ,
17+ isArchivedReport ,
1718 navigateToLinkedReportAction ,
1819} from '@libs/ReportUtils' ;
1920import { navigateToConciergeChatAndDeleteReport } from '@userActions/Report' ;
@@ -82,7 +83,7 @@ function ReportActionItemParentAction({
8283 const [ allAncestors , setAllAncestors ] = useState < Ancestor [ ] > ( [ ] ) ;
8384 const { isOffline} = useNetwork ( ) ;
8485 const { isInNarrowPaneModal} = useResponsiveLayout ( ) ;
85- const isReportArchived = useReportIsArchived ( report ?. reportID ) ;
86+ const [ reportNameValuePairs ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS , { canBeMissing : true } ) ;
8687
8788 useEffect ( ( ) => {
8889 const unsubscribeReports : Array < ( ) => void > = [ ] ;
@@ -126,7 +127,8 @@ function ReportActionItemParentAction({
126127 const ancestorReport = allReports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ ancestor . report . reportID } ` ] ;
127128 const canUserPerformWriteAction = canUserPerformWriteActionReportUtils ( ancestorReport ) ;
128129 const shouldDisplayThreadDivider = ! isTripPreview ( ancestor . reportAction ) ;
129-
130+ const reportNameValuePair = reportNameValuePairs ?. [ `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ ancestorReports . current ?. [ ancestor ?. report ?. reportID ] ?. reportID } ` ] ;
131+ const isAncestorReportArchived = isArchivedReport ( reportNameValuePair ) ;
130132 return (
131133 < OfflineWithFeedback
132134 key = { ancestor . reportAction . reportActionID }
@@ -139,14 +141,14 @@ function ReportActionItemParentAction({
139141 { shouldDisplayThreadDivider && (
140142 < ThreadDivider
141143 ancestor = { ancestor }
142- isLinkDisabled = { ! canCurrentUserOpenReport ( ancestorReports . current ?. [ ancestor ?. report ?. reportID ] , isReportArchived ) }
144+ isLinkDisabled = { ! canCurrentUserOpenReport ( ancestorReports . current ?. [ ancestor ?. report ?. reportID ] , isAncestorReportArchived ) }
143145 />
144146 ) }
145147 < ReportActionItem
146148 allReports = { allReports }
147149 policies = { policies }
148150 onPress = {
149- canCurrentUserOpenReport ( ancestorReports . current ?. [ ancestor ?. report ?. reportID ] , isReportArchived )
151+ canCurrentUserOpenReport ( ancestorReports . current ?. [ ancestor ?. report ?. reportID ] , isAncestorReportArchived )
150152 ? ( ) => navigateToLinkedReportAction ( ancestor , isInNarrowPaneModal , canUserPerformWriteAction , isOffline )
151153 : undefined
152154 }
0 commit comments