@@ -16,10 +16,10 @@ import usePrevious from '@hooks/usePrevious';
1616import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
1717import useTheme from '@hooks/useTheme' ;
1818import useThemeStyles from '@hooks/useThemeStyles' ;
19- import * as DraftCommentUtils from '@libs/DraftCommentUtils' ;
20- import * as OptionsListUtils from '@libs/OptionsListUtils' ;
21- import * as ReportActionsUtils from '@libs/ReportActionsUtils' ;
22- import * as ReportUtils from '@libs/ReportUtils' ;
19+ import { isValidDraftComment } from '@libs/DraftCommentUtils' ;
20+ import { getIOUReportIDOfLastAction , getLastMessageTextForReport } from '@libs/OptionsListUtils' ;
21+ import { getOriginalMessage , getSortedReportActionsForDisplay , isMoneyRequestAction } from '@libs/ReportActionsUtils' ;
22+ import { canUserPerformWriteAction } from '@libs/ReportUtils' ;
2323import variables from '@styles/variables' ;
2424import CONST from '@src/CONST' ;
2525import ONYXKEYS from '@src/ONYXKEYS' ;
@@ -118,11 +118,11 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
118118 const renderItem = useCallback (
119119 ( { item : reportID } : RenderItemProps ) : ReactElement => {
120120 const itemFullReport = reports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ reportID } ` ] ;
121- const itemParentReport = reports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ itemFullReport ?. parentReportID ?? '-1' } ` ] ;
121+ const itemParentReport = reports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ itemFullReport ?. parentReportID } ` ] ;
122122 const itemReportNameValuePairs = reportNameValuePairs ?. [ `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ reportID } ` ] ;
123123 const itemReportActions = reportActions ?. [ `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ reportID } ` ] ;
124124 const itemParentReportActions = reportActions ?. [ `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ itemFullReport ?. parentReportID } ` ] ;
125- const itemParentReportAction = itemParentReportActions ?. [ itemFullReport ?. parentReportActionID ?? '-1' ] ;
125+ const itemParentReportAction = itemFullReport ?. parentReportActionID ? itemParentReportActions ?. [ itemFullReport ?. parentReportActionID ] : undefined ;
126126
127127 let invoiceReceiverPolicyID = '-1' ;
128128 if ( itemFullReport ?. invoiceReceiver && 'policyID' in itemFullReport . invoiceReceiver ) {
@@ -133,26 +133,24 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
133133 }
134134 const itemInvoiceReceiverPolicy = policy ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ invoiceReceiverPolicyID } ` ] ;
135135
136- const iouReportIDOfLastAction = OptionsListUtils . getIOUReportIDOfLastAction ( itemFullReport ) ;
136+ const iouReportIDOfLastAction = getIOUReportIDOfLastAction ( itemFullReport ) ;
137137 const itemIouReportReportActions = iouReportIDOfLastAction ? reportActions ?. [ `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ iouReportIDOfLastAction } ` ] : undefined ;
138138
139139 const itemPolicy = policy ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ itemFullReport ?. policyID } ` ] ;
140- const transactionID = ReportActionsUtils . isMoneyRequestAction ( itemParentReportAction )
141- ? ReportActionsUtils . getOriginalMessage ( itemParentReportAction ) ?. IOUTransactionID ?? '-1'
142- : '-1' ;
140+ const transactionID = isMoneyRequestAction ( itemParentReportAction )
141+ ? getOriginalMessage ( itemParentReportAction ) ?. IOUTransactionID ?? CONST . DEFAULT_NUMBER_ID
142+ : CONST . DEFAULT_NUMBER_ID ;
143143 const itemTransaction = transactions ?. [ `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ] ;
144- const hasDraftComment = DraftCommentUtils . isValidDraftComment ( draftComments ?. [ `${ ONYXKEYS . COLLECTION . REPORT_DRAFT_COMMENT } ${ reportID } ` ] ) ;
144+ const hasDraftComment = isValidDraftComment ( draftComments ?. [ `${ ONYXKEYS . COLLECTION . REPORT_DRAFT_COMMENT } ${ reportID } ` ] ) ;
145145
146- const canUserPerformWriteAction = ReportUtils . canUserPerformWriteAction ( itemFullReport ) ;
147- const sortedReportActions = ReportActionsUtils . getSortedReportActionsForDisplay ( itemReportActions , canUserPerformWriteAction ) ;
146+ const canUserPerformWrite = canUserPerformWriteAction ( itemFullReport ) ;
147+ const sortedReportActions = getSortedReportActionsForDisplay ( itemReportActions , canUserPerformWrite ) ;
148148 const lastReportAction = sortedReportActions . at ( 0 ) ;
149149
150150 // Get the transaction for the last report action
151- let lastReportActionTransactionID = '' ;
152-
153- if ( ReportActionsUtils . isMoneyRequestAction ( lastReportAction ) ) {
154- lastReportActionTransactionID = ReportActionsUtils . getOriginalMessage ( lastReportAction ) ?. IOUTransactionID ?? '-1' ;
155- }
151+ const lastReportActionTransactionID = isMoneyRequestAction ( lastReportAction )
152+ ? getOriginalMessage ( lastReportAction ) ?. IOUTransactionID ?? CONST . DEFAULT_NUMBER_ID
153+ : CONST . DEFAULT_NUMBER_ID ;
156154 const lastReportActionTransaction = transactions ?. [ `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ lastReportActionTransactionID } ` ] ;
157155
158156 // SidebarUtils.getOptionData in OptionRowLHNData does not get re-evaluated when the linked task report changes, so we have the lastMessageTextFromReport evaluation logic here
@@ -167,7 +165,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
167165 }
168166 : null ;
169167 }
170- const lastMessageTextFromReport = OptionsListUtils . getLastMessageTextForReport ( itemFullReport , lastActorDetails , itemPolicy ) ;
168+ const lastMessageTextFromReport = getLastMessageTextForReport ( itemFullReport , lastActorDetails , itemPolicy ) ;
171169
172170 return (
173171 < OptionRowLHNData
0 commit comments