@@ -6,24 +6,15 @@ import type {LocaleContextProps} from '@components/LocaleContextProvider';
66import type { PartialPolicyForSidebar , ReportsToDisplayInLHN } from '@hooks/useSidebarOrderedReports' ;
77import CONST from '@src/CONST' ;
88import ONYXKEYS from '@src/ONYXKEYS' ;
9- import type {
10- Card ,
11- DraftReportComments ,
12- PersonalDetails ,
13- PersonalDetailsList ,
14- ReportActions ,
15- ReportAttributesDerivedValue ,
16- ReportNameValuePairs ,
17- Transaction ,
18- TransactionViolation ,
19- } from '@src/types/onyx' ;
9+ import type { Card , PersonalDetails , PersonalDetailsList , ReportActions , ReportAttributesDerivedValue , ReportNameValuePairs , Transaction , TransactionViolation } from '@src/types/onyx' ;
2010import type Beta from '@src/types/onyx/Beta' ;
2111import type { ReportAttributes } from '@src/types/onyx/DerivedValues' ;
2212import type { Errors } from '@src/types/onyx/OnyxCommon' ;
2313import type Policy from '@src/types/onyx/Policy' ;
2414import type PriorityMode from '@src/types/onyx/PriorityMode' ;
2515import type Report from '@src/types/onyx/Report' ;
2616import type ReportAction from '@src/types/onyx/ReportAction' ;
17+ import { hasValidDraftComment } from './DraftCommentUtils' ;
2718import { translateLocal } from './Localize' ;
2819import { getLastActorDisplayName , getLastMessageTextForReport , getPersonalDetailsForAccountIDs , shouldShowLastActorDisplayName } from './OptionsListUtils' ;
2920import Parser from './Parser' ;
@@ -188,7 +179,6 @@ function shouldDisplayReportInLHN(
188179 transactionViolations : OnyxCollection < TransactionViolation [ ] > ,
189180 isReportArchived ?: boolean ,
190181 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
191- draftReportComments ?: DraftReportComments ,
192182) {
193183 if ( ! report ) {
194184 return { shouldDisplay : false } ;
@@ -219,12 +209,7 @@ function shouldDisplayReportInLHN(
219209 // Check if report should override hidden status
220210 const isSystemChat = isSystemChatUtil ( report ) ;
221211 const shouldOverrideHidden =
222- ! ! draftReportComments ?. [ report . reportID ] ||
223- hasErrorsOtherThanFailedReceipt ||
224- isFocused ||
225- isSystemChat ||
226- ! ! report . isPinned ||
227- reportAttributes ?. [ report ?. reportID ] ?. requiresAttention ;
212+ hasValidDraftComment ( report . reportID ) || hasErrorsOtherThanFailedReceipt || isFocused || isSystemChat || ! ! report . isPinned || reportAttributes ?. [ report ?. reportID ] ?. requiresAttention ;
228213
229214 if ( isHidden && ! shouldOverrideHidden ) {
230215 return { shouldDisplay : false } ;
@@ -255,7 +240,6 @@ function getReportsToDisplayInLHN(
255240 transactionViolations : OnyxCollection < TransactionViolation [ ] > ,
256241 reportNameValuePairs ?: OnyxCollection < ReportNameValuePairs > ,
257242 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
258- draftReportComments ?: DraftReportComments ,
259243) {
260244 const isInFocusMode = priorityMode === CONST . PRIORITY_MODE . GSD ;
261245 const allReportsDictValues = reports ?? { } ;
@@ -275,7 +259,6 @@ function getReportsToDisplayInLHN(
275259 transactionViolations ,
276260 isArchivedReport ( reportNameValuePairs ?. [ `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ report . reportID } ` ] ) ,
277261 reportAttributes ,
278- draftReportComments ,
279262 ) ;
280263
281264 if ( shouldDisplay ) {
@@ -293,10 +276,10 @@ function updateReportsToDisplayInLHN(
293276 currentReportId : string | undefined ,
294277 isInFocusMode : boolean ,
295278 betas : OnyxEntry < Beta [ ] > ,
279+ policies : OnyxCollection < PartialPolicyForSidebar > ,
296280 transactionViolations : OnyxCollection < TransactionViolation [ ] > ,
297281 reportNameValuePairs ?: OnyxCollection < ReportNameValuePairs > ,
298282 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
299- draftReportComments ?: DraftReportComments ,
300283) {
301284 const displayedReportsCopy = { ...displayedReports } ;
302285 updatedReportsKeys . forEach ( ( reportID ) => {
@@ -314,7 +297,6 @@ function updateReportsToDisplayInLHN(
314297 transactionViolations ,
315298 isArchivedReport ( reportNameValuePairs ?. [ `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ report . reportID } ` ] ) ,
316299 reportAttributes ,
317- draftReportComments ,
318300 ) ;
319301
320302 if ( shouldDisplay ) {
@@ -333,7 +315,6 @@ function categorizeReportsForLHN(
333315 reportsToDisplay : ReportsToDisplayInLHN ,
334316 reportNameValuePairs ?: OnyxCollection < ReportNameValuePairs > ,
335317 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
336- draftReportComments ?: DraftReportComments ,
337318) {
338319 const pinnedAndGBRReports : MiniReport [ ] = [ ] ;
339320 const errorReports : MiniReport [ ] = [ ] ;
@@ -369,7 +350,7 @@ function categorizeReportsForLHN(
369350 const isPinned = ! ! report . isPinned ;
370351 const requiresAttention = ! ! reportAttributes ?. [ reportID ] ?. requiresAttention ;
371352 const hasErrors = ! ! report . hasErrorsOtherThanFailedReceipt ;
372- const hasDraft = ! ! reportID && ! ! draftReportComments ?. [ reportID ] ;
353+ const hasDraft = reportID ? hasValidDraftComment ( reportID ) : false ;
373354 const reportNameValuePairsKey = `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ reportID } ` ;
374355 const rNVPs = reportNameValuePairs ?. [ reportNameValuePairsKey ] ;
375356 const isArchived = isArchivedNonExpenseReport ( report , ! ! rNVPs ?. private_isArchived ) ;
@@ -494,7 +475,6 @@ function sortReportsToDisplayInLHN(
494475 localeCompare : LocaleContextProps [ 'localeCompare' ] ,
495476 reportNameValuePairs ?: OnyxCollection < ReportNameValuePairs > ,
496477 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
497- draftReportComments ?: DraftReportComments ,
498478) : string [ ] {
499479 Performance . markStart ( CONST . TIMING . GET_ORDERED_REPORT_IDS ) ;
500480
@@ -512,7 +492,7 @@ function sortReportsToDisplayInLHN(
512492 // - Sorted by reportDisplayName in GSD (focus) view mode
513493
514494 // Step 1: Categorize reports
515- const categories = categorizeReportsForLHN ( reportsToDisplay , reportNameValuePairs , reportAttributes , draftReportComments ) ;
495+ const categories = categorizeReportsForLHN ( reportsToDisplay , reportNameValuePairs , reportAttributes ) ;
516496
517497 // Step 2: Sort each category
518498 const sortedCategories = sortCategorizedReports ( categories , isInDefaultMode , localeCompare ) ;
0 commit comments