@@ -16,10 +16,10 @@ import usePrevious from '@hooks/usePrevious';
16
16
import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
17
17
import useTheme from '@hooks/useTheme' ;
18
18
import 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' ;
23
23
import variables from '@styles/variables' ;
24
24
import CONST from '@src/CONST' ;
25
25
import ONYXKEYS from '@src/ONYXKEYS' ;
@@ -118,11 +118,11 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
118
118
const renderItem = useCallback (
119
119
( { item : reportID } : RenderItemProps ) : ReactElement => {
120
120
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 } ` ] ;
122
122
const itemReportNameValuePairs = reportNameValuePairs ?. [ `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ reportID } ` ] ;
123
123
const itemReportActions = reportActions ?. [ `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ reportID } ` ] ;
124
124
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 ;
126
126
127
127
let invoiceReceiverPolicyID = '-1' ;
128
128
if ( itemFullReport ?. invoiceReceiver && 'policyID' in itemFullReport . invoiceReceiver ) {
@@ -133,26 +133,24 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
133
133
}
134
134
const itemInvoiceReceiverPolicy = policy ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ invoiceReceiverPolicyID } ` ] ;
135
135
136
- const iouReportIDOfLastAction = OptionsListUtils . getIOUReportIDOfLastAction ( itemFullReport ) ;
136
+ const iouReportIDOfLastAction = getIOUReportIDOfLastAction ( itemFullReport ) ;
137
137
const itemIouReportReportActions = iouReportIDOfLastAction ? reportActions ?. [ `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ iouReportIDOfLastAction } ` ] : undefined ;
138
138
139
139
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 ;
143
143
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 } ` ] ) ;
145
145
146
- const canUserPerformWriteAction = ReportUtils . canUserPerformWriteAction ( itemFullReport ) ;
147
- const sortedReportActions = ReportActionsUtils . getSortedReportActionsForDisplay ( itemReportActions , canUserPerformWriteAction ) ;
146
+ const canUserPerformWrite = canUserPerformWriteAction ( itemFullReport ) ;
147
+ const sortedReportActions = getSortedReportActionsForDisplay ( itemReportActions , canUserPerformWrite ) ;
148
148
const lastReportAction = sortedReportActions . at ( 0 ) ;
149
149
150
150
// 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 ;
156
154
const lastReportActionTransaction = transactions ?. [ `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ lastReportActionTransactionID } ` ] ;
157
155
158
156
// 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
167
165
}
168
166
: null ;
169
167
}
170
- const lastMessageTextFromReport = OptionsListUtils . getLastMessageTextForReport ( itemFullReport , lastActorDetails , itemPolicy ) ;
168
+ const lastMessageTextFromReport = getLastMessageTextForReport ( itemFullReport , lastActorDetails , itemPolicy ) ;
171
169
172
170
return (
173
171
< OptionRowLHNData
0 commit comments