@@ -6,7 +6,17 @@ 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 { Card , PersonalDetails , PersonalDetailsList , ReportActions , ReportAttributesDerivedValue , ReportNameValuePairs , Transaction , TransactionViolation } from '@src/types/onyx' ;
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' ;
1020import type Beta from '@src/types/onyx/Beta' ;
1121import type { ReportAttributes } from '@src/types/onyx/DerivedValues' ;
1222import type { Errors } from '@src/types/onyx/OnyxCommon' ;
@@ -15,7 +25,6 @@ import type PriorityMode from '@src/types/onyx/PriorityMode';
1525import type Report from '@src/types/onyx/Report' ;
1626import type ReportAction from '@src/types/onyx/ReportAction' ;
1727import { extractCollectionItemID } from './CollectionUtils' ;
18- import { hasValidDraftComment } from './DraftCommentUtils' ;
1928import { translateLocal } from './Localize' ;
2029import { getLastActorDisplayName , getLastMessageTextForReport , getPersonalDetailsForAccountIDs , shouldShowLastActorDisplayName } from './OptionsListUtils' ;
2130import Parser from './Parser' ;
@@ -207,6 +216,7 @@ function shouldDisplayReportInLHN(
207216 transactionViolations : OnyxCollection < TransactionViolation [ ] > ,
208217 isReportArchived ?: boolean ,
209218 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
219+ draftReportComments ?: DraftReportComments ,
210220) {
211221 if ( ! report ) {
212222 return { shouldDisplay : false } ;
@@ -237,7 +247,12 @@ function shouldDisplayReportInLHN(
237247 // Check if report should override hidden status
238248 const isSystemChat = isSystemChatUtil ( report ) ;
239249 const shouldOverrideHidden =
240- hasValidDraftComment ( report . reportID ) || hasErrorsOtherThanFailedReceipt || isFocused || isSystemChat || ! ! report . isPinned || reportAttributes ?. [ report ?. reportID ] ?. requiresAttention ;
250+ ! ! draftReportComments ?. [ report . reportID ] ||
251+ hasErrorsOtherThanFailedReceipt ||
252+ isFocused ||
253+ isSystemChat ||
254+ ! ! report . isPinned ||
255+ reportAttributes ?. [ report ?. reportID ] ?. requiresAttention ;
241256
242257 if ( isHidden && ! shouldOverrideHidden ) {
243258 return { shouldDisplay : false } ;
@@ -268,6 +283,7 @@ function getReportsToDisplayInLHN(
268283 transactionViolations : OnyxCollection < TransactionViolation [ ] > ,
269284 reportNameValuePairs ?: OnyxCollection < ReportNameValuePairs > ,
270285 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
286+ draftReportComments ?: DraftReportComments ,
271287) {
272288 const isInFocusMode = priorityMode === CONST . PRIORITY_MODE . GSD ;
273289 const allReportsDictValues = reports ?? { } ;
@@ -287,6 +303,7 @@ function getReportsToDisplayInLHN(
287303 transactionViolations ,
288304 isArchivedReport ( reportNameValuePairs ?. [ `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ report . reportID } ` ] ) ,
289305 reportAttributes ,
306+ draftReportComments ,
290307 ) ;
291308
292309 if ( shouldDisplay ) {
@@ -304,10 +321,10 @@ function updateReportsToDisplayInLHN(
304321 currentReportId : string | undefined ,
305322 isInFocusMode : boolean ,
306323 betas : OnyxEntry < Beta [ ] > ,
307- policies : OnyxCollection < PartialPolicyForSidebar > ,
308324 transactionViolations : OnyxCollection < TransactionViolation [ ] > ,
309325 reportNameValuePairs ?: OnyxCollection < ReportNameValuePairs > ,
310326 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
327+ draftReportComments ?: DraftReportComments ,
311328) {
312329 const displayedReportsCopy = { ...displayedReports } ;
313330 updatedReportsKeys . forEach ( ( reportID ) => {
@@ -325,6 +342,7 @@ function updateReportsToDisplayInLHN(
325342 transactionViolations ,
326343 isArchivedReport ( reportNameValuePairs ?. [ `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ report . reportID } ` ] ) ,
327344 reportAttributes ,
345+ draftReportComments ,
328346 ) ;
329347
330348 if ( shouldDisplay ) {
@@ -343,6 +361,7 @@ function categorizeReportsForLHN(
343361 reportsToDisplay : ReportsToDisplayInLHN ,
344362 reportNameValuePairs ?: OnyxCollection < ReportNameValuePairs > ,
345363 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
364+ draftReportComments ?: DraftReportComments ,
346365) {
347366 const pinnedAndGBRReports : MiniReport [ ] = [ ] ;
348367 const errorReports : MiniReport [ ] = [ ] ;
@@ -355,7 +374,7 @@ function categorizeReportsForLHN(
355374 const reportID = report . reportID ;
356375 const isPinned = ! ! report . isPinned ;
357376 const hasErrors = ! ! report . hasErrorsOtherThanFailedReceipt ;
358- const hasDraft = reportID ? hasValidDraftComment ( reportID ) : false ;
377+ const hasDraft = reportID ? ! ! draftReportComments ?. [ reportID ] : false ;
359378 const reportNameValuePairsKey = `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ reportID } ` ;
360379 const rNVPs = reportNameValuePairs ?. [ reportNameValuePairsKey ] ;
361380
@@ -469,6 +488,7 @@ function sortReportsToDisplayInLHN(
469488 localeCompare : LocaleContextProps [ 'localeCompare' ] ,
470489 reportNameValuePairs ?: OnyxCollection < ReportNameValuePairs > ,
471490 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
491+ draftReportComments ?: DraftReportComments ,
472492) : string [ ] {
473493 Performance . markStart ( CONST . TIMING . GET_ORDERED_REPORT_IDS ) ;
474494
@@ -486,7 +506,7 @@ function sortReportsToDisplayInLHN(
486506 // - Sorted by reportDisplayName in GSD (focus) view mode
487507
488508 // Step 1: Categorize reports
489- const categories = categorizeReportsForLHN ( reportsToDisplay , reportNameValuePairs , reportAttributes ) ;
509+ const categories = categorizeReportsForLHN ( reportsToDisplay , reportNameValuePairs , reportAttributes , draftReportComments ) ;
490510
491511 // Step 2: Sort each category
492512 const sortedCategories = sortCategorizedReports ( categories , isInDefaultMode , localeCompare ) ;
0 commit comments