@@ -62,6 +62,16 @@ function compareStringDates(a: string, b: string): 0 | 1 | -1 {
62
62
return 0 ;
63
63
}
64
64
65
+ /**
66
+ * A mini report object that contains only the necessary information to sort reports.
67
+ * This is used to avoid copying the entire report object and only the necessary information.
68
+ */
69
+ type MiniReport = {
70
+ reportID ?: string ;
71
+ displayName : string ;
72
+ lastVisibleActionCreated ?: string ;
73
+ } ;
74
+
65
75
/**
66
76
* @returns An array of reportIDs sorted in the proper order
67
77
*/
@@ -132,10 +142,10 @@ function getOrderedReportIDs(
132
142
// 4. Archived reports
133
143
// - Sorted by lastVisibleActionCreated in default (most recent) view mode
134
144
// - Sorted by reportDisplayName in GSD (focus) view mode
135
- const pinnedAndGBRReports : Array < OnyxEntry < Report > > = [ ] ;
136
- const draftReports : Array < OnyxEntry < Report > > = [ ] ;
137
- const nonArchivedReports : Array < OnyxEntry < Report > > = [ ] ;
138
- const archivedReports : Array < OnyxEntry < Report > > = [ ] ;
145
+ const pinnedAndGBRReports : MiniReport [ ] = [ ] ;
146
+ const draftReports : MiniReport [ ] = [ ] ;
147
+ const nonArchivedReports : MiniReport [ ] = [ ] ;
148
+ const archivedReports : MiniReport [ ] = [ ] ;
139
149
140
150
if ( currentPolicyID || policyMemberAccountIDs . length > 0 ) {
141
151
reportsToDisplay = reportsToDisplay . filter (
@@ -144,24 +154,23 @@ function getOrderedReportIDs(
144
154
}
145
155
// There are a few properties that need to be calculated for the report which are used when sorting reports.
146
156
reportsToDisplay . forEach ( ( reportToDisplay ) => {
147
- let report = reportToDisplay as OnyxEntry < Report > ;
148
- if ( report ) {
149
- report = {
150
- ...report ,
151
- displayName : ReportUtils . getReportName ( report ) ,
152
- } ;
153
- }
157
+ const report = reportToDisplay as OnyxEntry < Report > ;
158
+ const miniReport : MiniReport = {
159
+ reportID : report ?. reportID ,
160
+ displayName : ReportUtils . getReportName ( report ) ,
161
+ lastVisibleActionCreated : report ?. lastVisibleActionCreated ,
162
+ } ;
154
163
155
164
const isPinned = report ?. isPinned ?? false ;
156
165
const reportAction = ReportActionsUtils . getReportAction ( report ?. parentReportID ?? '' , report ?. parentReportActionID ?? '' ) ;
157
166
if ( isPinned || ReportUtils . requiresAttentionFromCurrentUser ( report , reportAction ) ) {
158
- pinnedAndGBRReports . push ( report ) ;
167
+ pinnedAndGBRReports . push ( miniReport ) ;
159
168
} else if ( hasValidDraftComment ( report ?. reportID ?? '' ) ) {
160
- draftReports . push ( report ) ;
169
+ draftReports . push ( miniReport ) ;
161
170
} else if ( ReportUtils . isArchivedRoom ( report ) ) {
162
- archivedReports . push ( report ) ;
171
+ archivedReports . push ( miniReport ) ;
163
172
} else {
164
- nonArchivedReports . push ( report ) ;
173
+ nonArchivedReports . push ( miniReport ) ;
165
174
}
166
175
} ) ;
167
176
0 commit comments