@@ -215,38 +215,45 @@ Onyx.connect({
215215 } ,
216216} ) ;
217217
218- const lastReportActions : ReportActions = { } ;
219- const allSortedReportActions : Record < string , ReportAction [ ] > = { } ;
220- const cachedOneTransactionThreadReportIDs : Record < string , string | undefined > = { } ;
221- let allReportActions : OnyxCollection < ReportActions > ;
218+ /** @deprecated Use sortedReportActionsData from ONYXKEYS.DERIVED.SORTED_REPORT_ACTIONS instead. Will be removed once all flows are migrated. */
219+ const deprecatedLastReportActions : ReportActions = { } ;
220+ /** @deprecated Use sortedReportActionsData from ONYXKEYS.DERIVED.SORTED_REPORT_ACTIONS instead. Will be removed once all flows are migrated. */
221+ const deprecatedAllSortedReportActions : Record < string , ReportAction [ ] > = { } ;
222+ /** @deprecated Use sortedReportActionsData from ONYXKEYS.DERIVED.SORTED_REPORT_ACTIONS instead. Will be removed once all flows are migrated. */
223+ const deprecatedCachedOneTransactionThreadReportIDs : Record < string , string | undefined > = { } ;
224+ /** @deprecated Use sortedReportActionsData from ONYXKEYS.DERIVED.SORTED_REPORT_ACTIONS instead. Will be removed once all flows are migrated. */
225+ let deprecatedAllReportActions : OnyxCollection < ReportActions > ;
222226Onyx . connect ( {
223227 key : ONYXKEYS . COLLECTION . REPORT_ACTIONS ,
224228 waitForCollectionCallback : true ,
225229 callback : ( actions ) => {
226230 if ( ! actions ) {
227231 return ;
228232 }
229-
230- allReportActions = actions ?? { } ;
233+ // eslint-disable-next-line @typescript-eslint/no-deprecated
234+ deprecatedAllReportActions = actions ?? { } ;
231235
232236 // Iterate over the report actions to build the sorted report actions objects
233- for ( const reportActions of Object . entries ( allReportActions ) ) {
237+ // eslint-disable-next-line @typescript-eslint/no-deprecated
238+ for ( const reportActions of Object . entries ( deprecatedAllReportActions ) ) {
234239 const reportID = reportActions [ 0 ] . split ( '_' ) . at ( 1 ) ;
235240 if ( ! reportID ) {
236241 continue ;
237242 }
238243
239244 const reportActionsArray = Object . values ( reportActions [ 1 ] ?? { } ) ;
240245 let sortedReportActions = getSortedReportActions ( withDEWRoutedActionsArray ( reportActionsArray ) , true ) ;
241- allSortedReportActions [ reportID ] = sortedReportActions ;
246+ // eslint-disable-next-line @typescript-eslint/no-deprecated
247+ deprecatedAllSortedReportActions [ reportID ] = sortedReportActions ;
242248 const report = allReports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ reportID } ` ] ;
243249 const chatReport = allReports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ report ?. chatReportID } ` ] ;
244250
245251 // If the report is a one-transaction report, we need to return the combined reportActions so that the LHN can display modifications
246252 // to the transaction thread or the report itself.
247253 // Cache the result for O(1) lookup in renderItem.
248254 const transactionThreadReportID = getOneTransactionThreadReportID ( report , chatReport , actions [ reportActions [ 0 ] ] ) ;
249- cachedOneTransactionThreadReportIDs [ reportID ] = transactionThreadReportID ;
255+ // eslint-disable-next-line @typescript-eslint/no-deprecated
256+ deprecatedCachedOneTransactionThreadReportIDs [ reportID ] = transactionThreadReportID ;
250257
251258 if ( transactionThreadReportID ) {
252259 const transactionThreadReportActionsArray = Object . values ( actions [ `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ transactionThreadReportID } ` ] ?? { } ) ;
@@ -255,9 +262,11 @@ Onyx.connect({
255262
256263 const firstReportAction = sortedReportActions . at ( 0 ) ;
257264 if ( ! firstReportAction ) {
258- delete lastReportActions [ reportID ] ;
265+ // eslint-disable-next-line @typescript-eslint/no-deprecated
266+ delete deprecatedLastReportActions [ reportID ] ;
259267 } else {
260- lastReportActions [ reportID ] = firstReportAction ;
268+ // eslint-disable-next-line @typescript-eslint/no-deprecated
269+ deprecatedLastReportActions [ reportID ] = firstReportAction ;
261270 }
262271 }
263272 } ,
@@ -618,7 +627,8 @@ function getLastMessageTextForReport({
618627 const canUserPerformWrite = canUserPerformWriteAction ( report , isReportArchived ) ;
619628 let lastReportAction = lastAction ?? getLastVisibleAction ( reportID , canUserPerformWrite , { } , undefined , visibleReportActionsDataParam ) ;
620629
621- const transactionThreadReportID = reportID ? cachedOneTransactionThreadReportIDs [ reportID ] : undefined ;
630+ // eslint-disable-next-line @typescript-eslint/no-deprecated
631+ const transactionThreadReportID = reportID ? deprecatedCachedOneTransactionThreadReportIDs [ reportID ] : undefined ;
622632
623633 if ( reportID && ! lastAction && transactionThreadReportID ) {
624634 lastReportAction =
@@ -648,7 +658,8 @@ function getLastMessageTextForReport({
648658 }
649659
650660 // some types of actions are filtered out for lastReportAction, in some cases we need to check the actual last action
651- const lastOriginalReportAction = reportID ? lastReportActions [ reportID ] : undefined ;
661+ // eslint-disable-next-line @typescript-eslint/no-deprecated
662+ const lastOriginalReportAction = reportID ? deprecatedLastReportActions [ reportID ] : undefined ;
652663 let lastMessageTextFromReport = '' ;
653664
654665 if ( isArchivedNonExpenseReport ( report , isReportArchived ) ) {
@@ -681,7 +692,8 @@ function getLastMessageTextForReport({
681692 const iouReportID = iouReport ?. reportID ;
682693 const reportCache = iouReportID ? visibleReportActionsDataParam ?. [ iouReportID ] : undefined ;
683694 const visibleReportActionsForIOUReport = reportCache && Object . keys ( reportCache ) . length > 0 ? visibleReportActionsDataParam : undefined ;
684- const iouReportActions = iouReportID ? allSortedReportActions [ iouReportID ] : undefined ;
695+ // eslint-disable-next-line @typescript-eslint/no-deprecated
696+ const iouReportActions = iouReportID ? deprecatedAllSortedReportActions [ iouReportID ] : undefined ;
685697 const canPerformWrite = canUserPerformWriteAction ( report , isReportArchived ) ;
686698 const lastIOUMoneyReportAction =
687699 iouReportID && iouReportActions
@@ -2253,6 +2265,8 @@ function prepareReportOptionsForDisplay(
22532265 config : GetValidReportsConfig ,
22542266 visibleReportActionsData : VisibleReportActionsDerivedValue = { } ,
22552267 reportAttributesDerived ?: ReportAttributesDerivedValue [ 'reports' ] ,
2268+ // eslint-disable-next-line @typescript-eslint/no-deprecated
2269+ sortedActions : Record < string , ReportAction [ ] > = deprecatedAllSortedReportActions ,
22562270 policyTags ?: OnyxCollection < PolicyTagLists > ,
22572271) : Array < SearchOption < Report > > {
22582272 const {
@@ -2305,7 +2319,7 @@ function prepareReportOptionsForDisplay(
23052319 const chatReport = allReports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ report . chatReportID } ` ] ;
23062320 const oneTransactionThreadReportID =
23072321 report . type === CONST . REPORT . TYPE . IOU || report . type === CONST . REPORT . TYPE . EXPENSE || report . type === CONST . REPORT . TYPE . INVOICE
2308- ? getOneTransactionThreadReportID ( report , chatReport , allSortedReportActions [ report . reportID ] )
2322+ ? getOneTransactionThreadReportID ( report , chatReport , sortedActions [ report . reportID ] )
23092323 : undefined ;
23102324 const oneTransactionThreadReport = oneTransactionThreadReportID ? allReports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ oneTransactionThreadReportID } ` ] : undefined ;
23112325
@@ -2315,11 +2329,11 @@ function prepareReportOptionsForDisplay(
23152329 let lastIOUCreationDate ;
23162330 // Add a field to sort the recent reports by the time of last IOU request for create actions
23172331 if ( preferRecentExpenseReports ) {
2318- const reportPreviewAction = allSortedReportActions [ option . reportID ] ?. find ( ( reportAction ) => isActionOfType ( reportAction , CONST . REPORT . ACTIONS . TYPE . REPORT_PREVIEW ) ) ;
2332+ const reportPreviewAction = sortedActions [ option . reportID ] ?. find ( ( reportAction ) => isActionOfType ( reportAction , CONST . REPORT . ACTIONS . TYPE . REPORT_PREVIEW ) ) ;
23192333
23202334 if ( reportPreviewAction ) {
23212335 const iouReportID = getIOUReportIDFromReportActionPreview ( reportPreviewAction ) ;
2322- const iouReportActions = iouReportID ? ( allSortedReportActions [ iouReportID ] ?? [ ] ) : [ ] ;
2336+ const iouReportActions = iouReportID ? ( sortedActions [ iouReportID ] ?? [ ] ) : [ ] ;
23232337 const lastIOUAction = iouReportActions . find ( ( iouAction ) => iouAction . actionName === CONST . REPORT . ACTIONS . TYPE . IOU ) ;
23242338 if ( lastIOUAction ) {
23252339 lastIOUCreationDate = lastIOUAction . lastModified ;
@@ -2440,6 +2454,7 @@ function getValidOptions(
24402454 countryCode = CONST . DEFAULT_COUNTRY_CODE ,
24412455 visibleReportActionsData = { } ,
24422456 reportAttributesDerived,
2457+ sortedActions,
24432458 ...config
24442459 } : GetOptionsConfig = { } ,
24452460) : Options {
@@ -2545,6 +2560,7 @@ function getValidOptions(
25452560 } ,
25462561 visibleReportActionsData ,
25472562 reportAttributesDerived ,
2563+ sortedActions ,
25482564 allPolicyTags ,
25492565 ) . at ( 0 ) ;
25502566 }
@@ -2567,6 +2583,7 @@ function getValidOptions(
25672583 } ,
25682584 visibleReportActionsData ,
25692585 reportAttributesDerived ,
2586+ sortedActions ,
25702587 allPolicyTags ,
25712588 ) ;
25722589
@@ -2585,6 +2602,7 @@ function getValidOptions(
25852602 } ,
25862603 visibleReportActionsData ,
25872604 reportAttributesDerived ,
2605+ sortedActions ,
25882606 allPolicyTags ,
25892607 ) ;
25902608 } else if ( recentAttendees && recentAttendees ?. length > 0 ) {
0 commit comments