From 753b21bd99a8958be891d53dce480986665f5447 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Tue, 28 Oct 2025 10:02:51 +0100 Subject: [PATCH 1/2] revert commit 52e93de from main --- src/hooks/useSearchTypeMenuSections.ts | 3 --- src/libs/SearchUIUtils.ts | 37 ++------------------------ 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/src/hooks/useSearchTypeMenuSections.ts b/src/hooks/useSearchTypeMenuSections.ts index af5bcfd7aca4..002cda8241e1 100644 --- a/src/hooks/useSearchTypeMenuSections.ts +++ b/src/hooks/useSearchTypeMenuSections.ts @@ -50,7 +50,6 @@ const useSearchTypeMenuSections = () => { const [currentUserLoginAndAccountID] = useOnyx(ONYXKEYS.SESSION, {selector: currentUserLoginAndAccountIDSelector, canBeMissing: false}); const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); const [savedSearches] = useOnyx(ONYXKEYS.SAVED_SEARCHES, {canBeMissing: true}); - const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true}); const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true}); const {isBetaEnabled} = usePermissions(); const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); @@ -70,7 +69,6 @@ const useSearchTypeMenuSections = () => { defaultExpensifyCard, isASAPSubmitBetaEnabled, hasViolations, - reports, ), [ currentUserLoginAndAccountID?.email, @@ -84,7 +82,6 @@ const useSearchTypeMenuSections = () => { isOffline, isASAPSubmitBetaEnabled, hasViolations, - reports, ], ); diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 313e5302777f..3af38ac1eadb 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -523,40 +523,11 @@ function getSuggestedSearches(accountID: number = CONST.DEFAULT_NUMBER_ID, defau }; } -/** - * Check if a user has any expense reports assigned to them for approval - */ -function hasPendingApprovalTasks(reports: OnyxCollection, currentUserAccountID?: number): boolean { - if (!reports || !currentUserAccountID) { - return false; - } - - const hasPending = Object.values(reports).some((report) => { - if (!report) { - return false; - } - - const isExpenseReport = report.type === CONST.REPORT.TYPE.EXPENSE; - const isSubmitted = report.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && report.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED; - const isAssignedToUser = report.managerID === currentUserAccountID; - - if (isExpenseReport && isSubmitted && isAssignedToUser) { - return true; - } - - return false; - }); - - return hasPending; -} - function getSuggestedSearchesVisibility( currentUserEmail: string | undefined, cardFeedsByPolicy: Record, policies: OnyxCollection, defaultExpensifyCard: CardFeedForDisplay | undefined, - reports?: OnyxCollection, - currentUserAccountID?: number, ): Record, boolean> { let shouldShowSubmitSuggestion = false; let shouldShowPaySuggestion = false; @@ -593,10 +564,7 @@ function getSuggestedSearchesVisibility( const isEligibleForSubmitSuggestion = isPaidPolicy; const isEligibleForPaySuggestion = isPaidPolicy && isPayer; - - const hasPendingApprovals = hasPendingApprovalTasks(reports, currentUserAccountID); - const isEligibleForApproveSuggestion = isPaidPolicy && isApprovalEnabled && (isApprover || isSubmittedTo || hasPendingApprovals); - + const isEligibleForApproveSuggestion = isPaidPolicy && isApprovalEnabled && (isApprover || isSubmittedTo); const isEligibleForExportSuggestion = isExporter && !hasExportError; const isEligibleForStatementsSuggestion = isPaidPolicy && !!policy.areCompanyCardsEnabled && hasCardFeed; const isEligibleForUnapprovedCashSuggestion = isPaidPolicy && isAdmin && isApprovalEnabled && isPaymentEnabled; @@ -1957,12 +1925,11 @@ function createTypeMenuSections( defaultExpensifyCard: CardFeedForDisplay | undefined, isASAPSubmitBetaEnabled: boolean, hasViolations: boolean, - reports?: OnyxCollection, ): SearchTypeMenuSection[] { const typeMenuSections: SearchTypeMenuSection[] = []; const suggestedSearches = getSuggestedSearches(currentUserAccountID, defaultCardFeed?.id); - const suggestedSearchesVisibility = getSuggestedSearchesVisibility(currentUserEmail, cardFeedsByPolicy, policies, defaultExpensifyCard, reports, currentUserAccountID); + const suggestedSearchesVisibility = getSuggestedSearchesVisibility(currentUserEmail, cardFeedsByPolicy, policies, defaultExpensifyCard); // Todo section { From 8f4f810c34905f47ee5c6a35962916bf51e88257 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Tue, 28 Oct 2025 12:17:49 +0100 Subject: [PATCH 2/2] fix typecheck --- tests/unit/Search/SearchUIUtilsTest.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index ac12e3d2a5a4..5027b2d3cac4 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -2019,7 +2019,7 @@ describe('SearchUIUtils', () => { describe('Test createTypeMenuItems', () => { it('should return the default menu items', () => { - const menuItems = SearchUIUtils.createTypeMenuSections(undefined, undefined, {}, undefined, {}, undefined, {}, false, undefined, true, false, undefined) + const menuItems = SearchUIUtils.createTypeMenuSections(undefined, undefined, {}, undefined, {}, undefined, {}, false, undefined, true, false) .map((section) => section.menuItems) .flat(); @@ -2652,7 +2652,7 @@ describe('SearchUIUtils', () => { } as OnyxTypes.Policy, }; - const response = SearchUIUtils.getSuggestedSearchesVisibility(adminEmail, {}, policies, undefined, {}, adminAccountID); + const response = SearchUIUtils.getSuggestedSearchesVisibility(adminEmail, {}, policies, undefined); expect(response.export).toBe(false); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion @@ -2666,7 +2666,7 @@ describe('SearchUIUtils', () => { successfulDate: new Date().toISOString(), }; - const response2 = SearchUIUtils.getSuggestedSearchesVisibility(adminEmail, {}, policies, undefined, {}, adminAccountID); + const response2 = SearchUIUtils.getSuggestedSearchesVisibility(adminEmail, {}, policies, undefined); expect(response2.export).toBe(true); }); });