@@ -5,16 +5,7 @@ import type {ValueOf} from 'type-fest';
55import type { PartialPolicyForSidebar , ReportsToDisplayInLHN } from '@hooks/useSidebarOrderedReports' ;
66import CONST from '@src/CONST' ;
77import ONYXKEYS from '@src/ONYXKEYS' ;
8- import type {
9- DraftReportComments ,
10- PersonalDetails ,
11- PersonalDetailsList ,
12- ReportActions ,
13- ReportAttributesDerivedValue ,
14- ReportNameValuePairs ,
15- Transaction ,
16- TransactionViolation ,
17- } from '@src/types/onyx' ;
8+ import type { PersonalDetails , PersonalDetailsList , ReportActions , ReportAttributesDerivedValue , ReportNameValuePairs , Transaction , TransactionViolation } from '@src/types/onyx' ;
189import type Beta from '@src/types/onyx/Beta' ;
1910import type { ReportAttributes } from '@src/types/onyx/DerivedValues' ;
2011import type { Errors } from '@src/types/onyx/OnyxCommon' ;
@@ -24,6 +15,7 @@ import type Report from '@src/types/onyx/Report';
2415import type ReportAction from '@src/types/onyx/ReportAction' ;
2516import { getExpensifyCardFromReportAction } from './CardMessageUtils' ;
2617import { extractCollectionItemID } from './CollectionUtils' ;
18+ import { hasValidDraftComment } from './DraftCommentUtils' ;
2719import localeCompare from './LocaleCompare' ;
2820import { translateLocal } from './Localize' ;
2921import { getLastActorDisplayName , getLastMessageTextForReport , getPersonalDetailsForAccountIDs , shouldShowLastActorDisplayName } from './OptionsListUtils' ;
@@ -215,7 +207,6 @@ function shouldDisplayReportInLHN(
215207 transactionViolations : OnyxCollection < TransactionViolation [ ] > ,
216208 reportNameValuePairs ?: OnyxCollection < ReportNameValuePairs > ,
217209 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
218- draftReportComments ?: DraftReportComments ,
219210) {
220211 if ( ! report ) {
221212 return { shouldDisplay : false } ;
@@ -247,12 +238,7 @@ function shouldDisplayReportInLHN(
247238 const isSystemChat = isSystemChatUtil ( report ) ;
248239 const isReportArchived = isArchivedReport ( reportNameValuePairs ) ;
249240 const shouldOverrideHidden =
250- ! ! draftReportComments ?. [ report . reportID ] ||
251- hasErrorsOtherThanFailedReceipt ||
252- isFocused ||
253- isSystemChat ||
254- ! ! report . isPinned ||
255- reportAttributes ?. [ report ?. reportID ] ?. requiresAttention ;
241+ hasValidDraftComment ( report . reportID ) || hasErrorsOtherThanFailedReceipt || isFocused || isSystemChat || ! ! report . isPinned || reportAttributes ?. [ report ?. reportID ] ?. requiresAttention ;
256242
257243 if ( isHidden && ! shouldOverrideHidden ) {
258244 return { shouldDisplay : false } ;
@@ -283,7 +269,6 @@ function getReportsToDisplayInLHN(
283269 transactionViolations : OnyxCollection < TransactionViolation [ ] > ,
284270 reportNameValuePairs ?: OnyxCollection < ReportNameValuePairs > ,
285271 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
286- draftReportComments ?: DraftReportComments ,
287272) {
288273 const isInFocusMode = priorityMode === CONST . PRIORITY_MODE . GSD ;
289274 const allReportsDictValues = reports ?? { } ;
@@ -303,7 +288,6 @@ function getReportsToDisplayInLHN(
303288 transactionViolations ,
304289 reportNameValuePairs ,
305290 reportAttributes ,
306- draftReportComments ,
307291 ) ;
308292
309293 if ( shouldDisplay ) {
@@ -321,10 +305,10 @@ function updateReportsToDisplayInLHN(
321305 currentReportId : string | undefined ,
322306 isInFocusMode : boolean ,
323307 betas : OnyxEntry < Beta [ ] > ,
308+ policies : OnyxCollection < PartialPolicyForSidebar > ,
324309 transactionViolations : OnyxCollection < TransactionViolation [ ] > ,
325310 reportNameValuePairs ?: OnyxCollection < ReportNameValuePairs > ,
326311 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
327- draftReportComments ?: DraftReportComments ,
328312) {
329313 const displayedReportsCopy = { ...displayedReports } ;
330314 updatedReportsKeys . forEach ( ( reportID ) => {
@@ -342,7 +326,6 @@ function updateReportsToDisplayInLHN(
342326 transactionViolations ,
343327 reportNameValuePairs ,
344328 reportAttributes ,
345- draftReportComments ,
346329 ) ;
347330
348331 if ( shouldDisplay ) {
@@ -363,7 +346,6 @@ function sortReportsToDisplayInLHN(
363346 priorityMode : OnyxEntry < PriorityMode > ,
364347 reportNameValuePairs ?: OnyxCollection < ReportNameValuePairs > ,
365348 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
366- draftReportComments ?: DraftReportComments ,
367349) : string [ ] {
368350 Performance . markStart ( CONST . TIMING . GET_ORDERED_REPORT_IDS ) ;
369351 const isInFocusMode = priorityMode === CONST . PRIORITY_MODE . GSD ;
@@ -400,7 +382,7 @@ function sortReportsToDisplayInLHN(
400382 pinnedAndGBRReports . push ( miniReport ) ;
401383 } else if ( report ?. hasErrorsOtherThanFailedReceipt ) {
402384 errorReports . push ( miniReport ) ;
403- } else if ( draftReportComments ?. [ report ?. reportID ] ) {
385+ } else if ( hasValidDraftComment ( report ?. reportID ) ) {
404386 draftReports . push ( miniReport ) ;
405387 } else if ( isArchivedNonExpenseReport ( report , ! ! rNVPs ?. private_isArchived ) ) {
406388 archivedReports . push ( miniReport ) ;
0 commit comments