From e86e35ef2307c031d32fc9a00e7f1f171815878f Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 2 Apr 2024 14:57:24 +0700 Subject: [PATCH 1/9] fix scan expense report and transaction are not hidden --- src/libs/SidebarUtils.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 2c628f397390..cab74d7c9e2e 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -12,6 +12,7 @@ import type Report from '@src/types/onyx/Report'; import type {ReportActions} from '@src/types/onyx/ReportAction'; import type ReportAction from '@src/types/onyx/ReportAction'; import type DeepValueOf from '@src/types/utils/DeepValueOf'; +import {isEmptyObject} from '@src/types/utils/EmptyObject'; import * as CollectionUtils from './CollectionUtils'; import localeCompare from './LocaleCompare'; import * as LocalePhoneNumber from './LocalePhoneNumber'; @@ -91,7 +92,10 @@ function getOrderedReportIDs( const isFocused = report.reportID === currentReportId; const hasErrors = Object.keys(OptionsListUtils.getAllReportErrors(report, reportActions) ?? {}).length !== 0; const hasBrickError = hasErrors || doesReportHaveViolations ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; - const shouldOverrideHidden = hasBrickError || isFocused || report.isPinned; + const allReportErrors = OptionsListUtils.getAllReportErrors(report, reportActions); + const hasBrickErrorOfNonFailedReceipt = + hasBrickError && (isEmptyObject(allReportErrors) || Object.values(allReportErrors).some((error) => error?.[0] !== 'report.genericSmartscanFailureMessage')); + const shouldOverrideHidden = hasBrickErrorOfNonFailedReceipt || isFocused || report.isPinned; if (isHidden && !shouldOverrideHidden) { return false; } From cc63feef2ecde6e2ba2c11e0c63e11f69eb6c51b Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 3 Apr 2024 16:47:37 +0700 Subject: [PATCH 2/9] fix update hasNonFailedReceiptError variable --- src/libs/SidebarUtils.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index cab74d7c9e2e..8d1ba8450aca 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -90,12 +90,12 @@ function getOrderedReportIDs( betas.includes(CONST.BETAS.VIOLATIONS) && !!parentReportAction && ReportUtils.doesTransactionThreadHaveViolations(report, transactionViolations, parentReportAction); const isHidden = report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; const isFocused = report.reportID === currentReportId; - const hasErrors = Object.keys(OptionsListUtils.getAllReportErrors(report, reportActions) ?? {}).length !== 0; + const allReportErrors = OptionsListUtils.getAllReportErrors(report, reportActions) ?? {}; + const hasErrors = Object.keys(allReportErrors).length !== 0; const hasBrickError = hasErrors || doesReportHaveViolations ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; - const allReportErrors = OptionsListUtils.getAllReportErrors(report, reportActions); - const hasBrickErrorOfNonFailedReceipt = - hasBrickError && (isEmptyObject(allReportErrors) || Object.values(allReportErrors).some((error) => error?.[0] !== 'report.genericSmartscanFailureMessage')); - const shouldOverrideHidden = hasBrickErrorOfNonFailedReceipt || isFocused || report.isPinned; + + const hasNonFailedReceiptError = isEmptyObject(allReportErrors) || Object.values(allReportErrors).some((error) => error?.[0] !== 'report.genericSmartscanFailureMessage'); + const shouldOverrideHidden = (hasBrickError && hasNonFailedReceiptError) || isFocused || report.isPinned; if (isHidden && !shouldOverrideHidden) { return false; } From 20acf25c97e3c2c4c2032257def0543c62d8c1b3 Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 3 Apr 2024 16:54:18 +0700 Subject: [PATCH 3/9] fix remove redundant line break --- src/libs/SidebarUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 8d1ba8450aca..ad30c9f71f7a 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -93,7 +93,6 @@ function getOrderedReportIDs( const allReportErrors = OptionsListUtils.getAllReportErrors(report, reportActions) ?? {}; const hasErrors = Object.keys(allReportErrors).length !== 0; const hasBrickError = hasErrors || doesReportHaveViolations ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; - const hasNonFailedReceiptError = isEmptyObject(allReportErrors) || Object.values(allReportErrors).some((error) => error?.[0] !== 'report.genericSmartscanFailureMessage'); const shouldOverrideHidden = (hasBrickError && hasNonFailedReceiptError) || isFocused || report.isPinned; if (isHidden && !shouldOverrideHidden) { From 5784171992a25a8b908ff7d05e0cd79cdf288d6e Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 4 Apr 2024 14:11:30 +0700 Subject: [PATCH 4/9] fix rename variable --- src/libs/SidebarUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index ad30c9f71f7a..0ab9adc2705c 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -93,8 +93,8 @@ function getOrderedReportIDs( const allReportErrors = OptionsListUtils.getAllReportErrors(report, reportActions) ?? {}; const hasErrors = Object.keys(allReportErrors).length !== 0; const hasBrickError = hasErrors || doesReportHaveViolations ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; - const hasNonFailedReceiptError = isEmptyObject(allReportErrors) || Object.values(allReportErrors).some((error) => error?.[0] !== 'report.genericSmartscanFailureMessage'); - const shouldOverrideHidden = (hasBrickError && hasNonFailedReceiptError) || isFocused || report.isPinned; + const hasErrorsOtherThanFailedReceipt = hasErrors || Object.values(allReportErrors).some((error) => error?.[0] !== 'report.genericSmartscanFailureMessage'); + const shouldOverrideHidden = (hasBrickError && hasErrorsOtherThanFailedReceipt) || isFocused || report.isPinned; if (isHidden && !shouldOverrideHidden) { return false; } From 890efed12db417952d38e5f08252c29f0ebbe6ab Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 4 Apr 2024 14:19:02 +0700 Subject: [PATCH 5/9] fix lint --- src/libs/SidebarUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 0ab9adc2705c..64650f86fe8c 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -12,7 +12,6 @@ import type Report from '@src/types/onyx/Report'; import type {ReportActions} from '@src/types/onyx/ReportAction'; import type ReportAction from '@src/types/onyx/ReportAction'; import type DeepValueOf from '@src/types/utils/DeepValueOf'; -import {isEmptyObject} from '@src/types/utils/EmptyObject'; import * as CollectionUtils from './CollectionUtils'; import localeCompare from './LocaleCompare'; import * as LocalePhoneNumber from './LocalePhoneNumber'; From 1a13943bee341e73457cba569a7e89e7496d19eb Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 10 Apr 2024 14:49:44 +0700 Subject: [PATCH 6/9] fix expense report is not hidden --- src/libs/SidebarUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 8d59d36a92b0..8d9e9e5dd707 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -96,7 +96,7 @@ function getOrderedReportIDs( const allReportErrors = OptionsListUtils.getAllReportErrors(report, reportActions) ?? {}; const hasErrors = Object.keys(allReportErrors).length !== 0; const hasBrickError = hasErrors || doesReportHaveViolations ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; - const hasErrorsOtherThanFailedReceipt = hasErrors || Object.values(allReportErrors).some((error) => error?.[0] !== 'report.genericSmartscanFailureMessage'); + const hasErrorsOtherThanFailedReceipt = !hasErrors || Object.values(allReportErrors).some((error) => error?.[0] !== 'report.genericSmartscanFailureMessage'); const shouldOverrideHidden = (hasBrickError && hasErrorsOtherThanFailedReceipt) || isFocused || report.isPinned; if (isHidden && !shouldOverrideHidden) { return false; From 1c17d75d6ea4f7890dc1a4620c2f7fd4c691e71d Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 10 Apr 2024 17:41:26 +0700 Subject: [PATCH 7/9] fix update hasErrorsOtherThanFailedReceipt --- src/libs/SidebarUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 8d9e9e5dd707..ce244d406640 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -96,7 +96,7 @@ function getOrderedReportIDs( const allReportErrors = OptionsListUtils.getAllReportErrors(report, reportActions) ?? {}; const hasErrors = Object.keys(allReportErrors).length !== 0; const hasBrickError = hasErrors || doesReportHaveViolations ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; - const hasErrorsOtherThanFailedReceipt = !hasErrors || Object.values(allReportErrors).some((error) => error?.[0] !== 'report.genericSmartscanFailureMessage'); + const hasErrorsOtherThanFailedReceipt = doesReportHaveViolations || Object.values(allReportErrors).some((error) => error?.[0] !== 'report.genericSmartscanFailureMessage'); const shouldOverrideHidden = (hasBrickError && hasErrorsOtherThanFailedReceipt) || isFocused || report.isPinned; if (isHidden && !shouldOverrideHidden) { return false; From 7d02b9017a74d6c7c7144fa181e77d8487304684 Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 11 Apr 2024 20:56:58 +0700 Subject: [PATCH 8/9] fix remove hasBrickError --- src/libs/SidebarUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index ce244d406640..15aa4bb6dbb9 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -97,7 +97,7 @@ function getOrderedReportIDs( const hasErrors = Object.keys(allReportErrors).length !== 0; const hasBrickError = hasErrors || doesReportHaveViolations ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; const hasErrorsOtherThanFailedReceipt = doesReportHaveViolations || Object.values(allReportErrors).some((error) => error?.[0] !== 'report.genericSmartscanFailureMessage'); - const shouldOverrideHidden = (hasBrickError && hasErrorsOtherThanFailedReceipt) || isFocused || report.isPinned; + const shouldOverrideHidden = hasErrorsOtherThanFailedReceipt || isFocused || report.isPinned; if (isHidden && !shouldOverrideHidden) { return false; } From f9874383ea9c029f3beb7d0bd0c84c136ddbbf60 Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 11 Apr 2024 20:58:40 +0700 Subject: [PATCH 9/9] fix lint --- src/libs/SidebarUtils.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 15aa4bb6dbb9..5a6e31a56e58 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -94,8 +94,6 @@ function getOrderedReportIDs( const isHidden = report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; const isFocused = report.reportID === currentReportId; const allReportErrors = OptionsListUtils.getAllReportErrors(report, reportActions) ?? {}; - const hasErrors = Object.keys(allReportErrors).length !== 0; - const hasBrickError = hasErrors || doesReportHaveViolations ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; const hasErrorsOtherThanFailedReceipt = doesReportHaveViolations || Object.values(allReportErrors).some((error) => error?.[0] !== 'report.genericSmartscanFailureMessage'); const shouldOverrideHidden = hasErrorsOtherThanFailedReceipt || isFocused || report.isPinned; if (isHidden && !shouldOverrideHidden) {