From 7856257bec266a3d3ca5da3932bad105eb331d51 Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Fri, 30 Aug 2024 12:56:17 -0600 Subject: [PATCH 1/3] Show report in LHN if manager without parent access --- src/libs/ReportUtils.ts | 8 ++++++++ src/libs/SidebarUtils.ts | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 1968423a864c..c9980472df5c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -7728,6 +7728,13 @@ function getApprovalChain(policy: OnyxEntry, employeeAccountID: number, return approvalChain; } +function isSubmittedExpenseReportManagerWithoutParentAccess(report: OnyxEntry) { + return isExpenseReport(report) + && report?.hasParentAccess === false + && report?.managerID === currentUserAccountID + && isProcessingReport(report); +} + export { addDomainToShortMention, completeShortMention, @@ -7923,6 +7930,7 @@ export { isEmptyReport, isRootGroupChat, isExpenseReport, + isSubmittedExpenseReportManagerWithoutParentAccess, isExpenseRequest, isExpensifyOnlyParticipantInReport, isGroupChat, diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index dedd608ce77d..0b11946e18b0 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -129,7 +129,8 @@ function getOrderedReportIDs( return; } const isSystemChat = ReportUtils.isSystemChat(report); - const shouldOverrideHidden = hasValidDraftComment(report.reportID) || hasErrorsOtherThanFailedReceipt || isFocused || isSystemChat || report.isPinned; + const isSubmittedExpenseReportManagerWithoutParentAccess = ReportUtils.isSubmittedExpenseReportManagerWithoutParentAccess(report); + const shouldOverrideHidden = hasValidDraftComment(report.reportID) || hasErrorsOtherThanFailedReceipt || isFocused || isSystemChat || report.isPinned || isSubmittedExpenseReportManagerWithoutParentAccess; if (isHidden && !shouldOverrideHidden) { return; } From cfa53ab289264a404f75fee64cd0b4cab1b5d9af Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Fri, 30 Aug 2024 13:30:41 -0600 Subject: [PATCH 2/3] Prettify --- src/libs/ReportUtils.ts | 5 +---- src/libs/SidebarUtils.ts | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index c9980472df5c..1151688ebc0a 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -7729,10 +7729,7 @@ function getApprovalChain(policy: OnyxEntry, employeeAccountID: number, } function isSubmittedExpenseReportManagerWithoutParentAccess(report: OnyxEntry) { - return isExpenseReport(report) - && report?.hasParentAccess === false - && report?.managerID === currentUserAccountID - && isProcessingReport(report); + return isExpenseReport(report) && report?.hasParentAccess === false && report?.managerID === currentUserAccountID && isProcessingReport(report); } export { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 0b11946e18b0..1993518e5c2c 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -130,7 +130,8 @@ function getOrderedReportIDs( } const isSystemChat = ReportUtils.isSystemChat(report); const isSubmittedExpenseReportManagerWithoutParentAccess = ReportUtils.isSubmittedExpenseReportManagerWithoutParentAccess(report); - const shouldOverrideHidden = hasValidDraftComment(report.reportID) || hasErrorsOtherThanFailedReceipt || isFocused || isSystemChat || report.isPinned || isSubmittedExpenseReportManagerWithoutParentAccess; + const shouldOverrideHidden = + hasValidDraftComment(report.reportID) || hasErrorsOtherThanFailedReceipt || isFocused || isSystemChat || report.isPinned || isSubmittedExpenseReportManagerWithoutParentAccess; if (isHidden && !shouldOverrideHidden) { return; } From 410d6f68a7fefc6c2fb868e7e97c63819f8bc8d4 Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Fri, 30 Aug 2024 13:56:52 -0600 Subject: [PATCH 3/3] Dont prefer nullish coalescing --- src/libs/SidebarUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 1993518e5c2c..0e84f5c9944c 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -131,6 +131,7 @@ function getOrderedReportIDs( const isSystemChat = ReportUtils.isSystemChat(report); const isSubmittedExpenseReportManagerWithoutParentAccess = ReportUtils.isSubmittedExpenseReportManagerWithoutParentAccess(report); const shouldOverrideHidden = + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing hasValidDraftComment(report.reportID) || hasErrorsOtherThanFailedReceipt || isFocused || isSystemChat || report.isPinned || isSubmittedExpenseReportManagerWithoutParentAccess; if (isHidden && !shouldOverrideHidden) { return;