From 93f9b3bee409f0b30c06d78e4df84a32084b06e1 Mon Sep 17 00:00:00 2001 From: "huult (via MelvinBot)" Date: Tue, 10 Mar 2026 04:59:23 +0000 Subject: [PATCH 1/6] Use comprehensive approver check for insights visibility The isApprover variable in getSuggestedSearchesVisibility only checked policy.approver (the single default approver), missing intermediate approvers configured via submitsTo/forwardsTo/overLimitForwardsTo in the employee list. This caused non-admin workflow approvers to not see the Top Spenders and Spend Over Time insights. Replace the narrow check with the existing isApprover utility from Policy/Member.ts which covers all approval routing fields. Co-authored-by: huult --- src/libs/SearchUIUtils.ts | 11 +++-- tests/unit/Search/SearchUIUtilsTest.ts | 60 ++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index ac28aeba4633..9c3fc74e965b 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -84,6 +84,7 @@ import type IconAsset from '@src/types/utils/IconAsset'; import arraysEqual from '@src/utils/arraysEqual'; import {hasSynchronizationErrorMessage} from './actions/connections'; import {canApproveIOU, canIOUBePaid, canSubmitReport, startMoneyRequest} from './actions/IOU'; +import {isApprover as isApproverUtils} from './actions/Policy/Member'; import {setIsOpenConfirmNavigateExpensifyClassicModalOpen} from './actions/isOpenConfirmNavigateExpensifyClassicModal'; import {createTransactionThreadReport} from './actions/Report'; import type {TransactionPreviewData} from './actions/Search'; @@ -984,7 +985,9 @@ function getSuggestedSearchesVisibility( const isPayer = isPolicyPayer(policy, currentUserEmail); const isAdmin = policy.role === CONST.POLICY.ROLE.ADMIN; const isExporter = policy.exporter === currentUserEmail; - const isApprover = policy.approver === currentUserEmail; + const isUserApprover = currentUserEmail && policy + ? isApproverUtils(policy, currentUserEmail) + : policy.approver === currentUserEmail; const isApprovalEnabled = policy.approvalMode ? policy.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL : false; const hasExportError = (Object.keys(policy.connections ?? {}) as ConnectionName[]).some((connection) => { @@ -1000,7 +1003,7 @@ function getSuggestedSearchesVisibility( const isEligibleForSubmitSuggestion = isPaidPolicy; const isEligibleForPaySuggestion = isPaidPolicy && isPayer; - const isPolicyEligibleForApproveSuggestion = isPaidPolicy && isEligibleForApproveSuggestion(policy.approvalMode, isApprover, isSubmittedTo); + const isPolicyEligibleForApproveSuggestion = isPaidPolicy && isEligibleForApproveSuggestion(policy.approvalMode, isUserApprover, isSubmittedTo); const isEligibleForExportSuggestion = isExporter && !hasExportError; const isEligibleForStatementsSuggestion = isPaidPolicy && !!policy.areCompanyCardsEnabled && hasCardFeed; const isEligibleForUnapprovedCashSuggestion = isPaidPolicy && isAdmin && isApprovalEnabled && isPaymentEnabled; @@ -1009,10 +1012,10 @@ function getSuggestedSearchesVisibility( const isEligibleForReimbursementsSuggestion = isPaidPolicy && isAdmin && isPaymentEnabled && hasVBBA && hasReimburser; const isAuditor = policy.role === CONST.POLICY.ROLE.AUDITOR; const memberCount = Object.keys(policy.employeeList ?? {}).length; - const isEligibleForTopSpendersSuggestion = isPaidPolicy && (isAdmin || isAuditor || isApprover) && memberCount >= 2; + const isEligibleForTopSpendersSuggestion = isPaidPolicy && (isAdmin || isAuditor || isUserApprover) && memberCount >= 2; const isEligibleForTopCategoriesSuggestion = isPaidPolicy && policy.areCategoriesEnabled === true; const isEligibleForTopMerchantsSuggestion = isPaidPolicy; - const isEligibleForSpendOverTimeSuggestion = isPaidPolicy && (isAdmin || isAuditor || isApprover); + const isEligibleForSpendOverTimeSuggestion = isPaidPolicy && (isAdmin || isAuditor || isUserApprover); shouldShowSubmitSuggestion ||= isEligibleForSubmitSuggestion; shouldShowPaySuggestion ||= isEligibleForPaySuggestion; diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index 59b0bf309d88..419158c5bf18 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -6116,6 +6116,66 @@ describe('SearchUIUtils', () => { expect(searchQuery).toContain(`view:${CONST.SEARCH.VIEW.PIE}`); }); + + test('Should show Top Spenders for workflow approver (submitsTo) in paid policy', () => { + const workflowApproverEmail = 'workflow-approver@policy.com'; + const policyKey = `policy_${policyID}`; + + const policies: OnyxCollection = { + [policyKey]: { + id: policyID, + type: CONST.POLICY.TYPE.TEAM, + approver: 'someone-else@policy.com', + employeeList: { + 'employee1@policy.com': {submitsTo: workflowApproverEmail, forwardsTo: ''}, + 'employee2@policy.com': {submitsTo: '', forwardsTo: ''}, + }, + } as OnyxTypes.Policy, + }; + + const response = SearchUIUtils.getSuggestedSearchesVisibility(workflowApproverEmail, {}, policies, undefined); + expect(response.visibility.topSpenders).toBe(true); + }); + + test('Should show Spend Over Time for workflow approver (forwardsTo) in paid policy', () => { + const workflowApproverEmail = 'workflow-approver@policy.com'; + const policyKey = `policy_${policyID}`; + + const policies: OnyxCollection = { + [policyKey]: { + id: policyID, + type: CONST.POLICY.TYPE.TEAM, + approver: 'someone-else@policy.com', + employeeList: { + 'employee1@policy.com': {submitsTo: '', forwardsTo: workflowApproverEmail}, + 'employee2@policy.com': {submitsTo: '', forwardsTo: ''}, + }, + } as OnyxTypes.Policy, + }; + + const response = SearchUIUtils.getSuggestedSearchesVisibility(workflowApproverEmail, {}, policies, undefined); + expect(response.visibility.spendOverTime).toBe(true); + }); + + test('Should hide Top Spenders for regular member who is not a workflow approver', () => { + const regularEmail = 'regular@policy.com'; + const policyKey = `policy_${policyID}`; + + const policies: OnyxCollection = { + [policyKey]: { + id: policyID, + type: CONST.POLICY.TYPE.TEAM, + approver: 'someone-else@policy.com', + employeeList: { + 'employee1@policy.com': {submitsTo: 'someone-else@policy.com', forwardsTo: ''}, + [regularEmail]: {submitsTo: '', forwardsTo: ''}, + }, + } as OnyxTypes.Policy, + }; + + const response = SearchUIUtils.getSuggestedSearchesVisibility(regularEmail, {}, policies, undefined); + expect(response.visibility.topSpenders).toBe(false); + }); }); describe('Test getSuggestedSearches sort defaults', () => { From c8c64d9075d3640445a49156d9ca4a421282a78c Mon Sep 17 00:00:00 2001 From: "huult (via MelvinBot)" Date: Tue, 10 Mar 2026 05:03:27 +0000 Subject: [PATCH 2/6] Fix: Run Prettier on SearchUIUtils.ts Co-authored-by: huult --- src/libs/SearchUIUtils.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 9c3fc74e965b..dfe7945c395e 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -84,8 +84,8 @@ import type IconAsset from '@src/types/utils/IconAsset'; import arraysEqual from '@src/utils/arraysEqual'; import {hasSynchronizationErrorMessage} from './actions/connections'; import {canApproveIOU, canIOUBePaid, canSubmitReport, startMoneyRequest} from './actions/IOU'; -import {isApprover as isApproverUtils} from './actions/Policy/Member'; import {setIsOpenConfirmNavigateExpensifyClassicModalOpen} from './actions/isOpenConfirmNavigateExpensifyClassicModal'; +import {isApprover as isApproverUtils} from './actions/Policy/Member'; import {createTransactionThreadReport} from './actions/Report'; import type {TransactionPreviewData} from './actions/Search'; import {setOptimisticDataForTransactionThreadPreview} from './actions/Search'; @@ -985,9 +985,7 @@ function getSuggestedSearchesVisibility( const isPayer = isPolicyPayer(policy, currentUserEmail); const isAdmin = policy.role === CONST.POLICY.ROLE.ADMIN; const isExporter = policy.exporter === currentUserEmail; - const isUserApprover = currentUserEmail && policy - ? isApproverUtils(policy, currentUserEmail) - : policy.approver === currentUserEmail; + const isUserApprover = currentUserEmail && policy ? isApproverUtils(policy, currentUserEmail) : policy.approver === currentUserEmail; const isApprovalEnabled = policy.approvalMode ? policy.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL : false; const hasExportError = (Object.keys(policy.connections ?? {}) as ConnectionName[]).some((connection) => { From f53f937323c85782b80e705603d32d09db9cc22b Mon Sep 17 00:00:00 2001 From: "huult (via MelvinBot)" Date: Tue, 10 Mar 2026 05:08:24 +0000 Subject: [PATCH 3/6] Fix TypeScript errors in SearchUIUtilsTest by casting through unknown The test Policy objects are intentionally partial (only the fields needed for the test), so direct `as OnyxTypes.Policy` fails because too many required properties are missing. Cast via `unknown` first. Co-authored-by: huult --- 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 419158c5bf18..5746da59b1f0 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -6130,7 +6130,7 @@ describe('SearchUIUtils', () => { 'employee1@policy.com': {submitsTo: workflowApproverEmail, forwardsTo: ''}, 'employee2@policy.com': {submitsTo: '', forwardsTo: ''}, }, - } as OnyxTypes.Policy, + } as unknown as OnyxTypes.Policy, }; const response = SearchUIUtils.getSuggestedSearchesVisibility(workflowApproverEmail, {}, policies, undefined); @@ -6150,7 +6150,7 @@ describe('SearchUIUtils', () => { 'employee1@policy.com': {submitsTo: '', forwardsTo: workflowApproverEmail}, 'employee2@policy.com': {submitsTo: '', forwardsTo: ''}, }, - } as OnyxTypes.Policy, + } as unknown as OnyxTypes.Policy, }; const response = SearchUIUtils.getSuggestedSearchesVisibility(workflowApproverEmail, {}, policies, undefined); @@ -6170,7 +6170,7 @@ describe('SearchUIUtils', () => { 'employee1@policy.com': {submitsTo: 'someone-else@policy.com', forwardsTo: ''}, [regularEmail]: {submitsTo: '', forwardsTo: ''}, }, - } as OnyxTypes.Policy, + } as unknown as OnyxTypes.Policy, }; const response = SearchUIUtils.getSuggestedSearchesVisibility(regularEmail, {}, policies, undefined); From 4b6068d46b9e5f9a92afaaac0680d8e48788389d Mon Sep 17 00:00:00 2001 From: "huult (via MelvinBot)" Date: Tue, 10 Mar 2026 05:57:15 +0000 Subject: [PATCH 4/6] Remove side-effectful Policy/Member import; inline and consolidate approver check - Remove import of isApprover from actions/Policy/Member to avoid eagerly registering Onyx listeners (top-level Onyx.connect calls) whenever SearchUIUtils is loaded - Inline the approver logic and consolidate with isSubmittedTo into a single pass over policy.employeeList, eliminating duplicate iteration - Simplify by removing unnecessary ternary guard (policy is already null-checked) Co-authored-by: huult --- src/libs/SearchUIUtils.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index dfe7945c395e..c5192dfdefb8 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -85,7 +85,6 @@ import arraysEqual from '@src/utils/arraysEqual'; import {hasSynchronizationErrorMessage} from './actions/connections'; import {canApproveIOU, canIOUBePaid, canSubmitReport, startMoneyRequest} from './actions/IOU'; import {setIsOpenConfirmNavigateExpensifyClassicModalOpen} from './actions/isOpenConfirmNavigateExpensifyClassicModal'; -import {isApprover as isApproverUtils} from './actions/Policy/Member'; import {createTransactionThreadReport} from './actions/Report'; import type {TransactionPreviewData} from './actions/Search'; import {setOptimisticDataForTransactionThreadPreview} from './actions/Search'; @@ -985,7 +984,19 @@ function getSuggestedSearchesVisibility( const isPayer = isPolicyPayer(policy, currentUserEmail); const isAdmin = policy.role === CONST.POLICY.ROLE.ADMIN; const isExporter = policy.exporter === currentUserEmail; - const isUserApprover = currentUserEmail && policy ? isApproverUtils(policy, currentUserEmail) : policy.approver === currentUserEmail; + let isSubmittedTo = false; + let isUserApprover = policy.approver === currentUserEmail; + for (const employee of Object.values(policy.employeeList ?? {})) { + if (employee?.submitsTo === currentUserEmail || employee?.forwardsTo === currentUserEmail) { + isSubmittedTo = true; + isUserApprover = true; + } else if (employee?.overLimitForwardsTo === currentUserEmail) { + isUserApprover = true; + } + if (isSubmittedTo && isUserApprover) { + break; + } + } const isApprovalEnabled = policy.approvalMode ? policy.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL : false; const hasExportError = (Object.keys(policy.connections ?? {}) as ConnectionName[]).some((connection) => { @@ -995,9 +1006,6 @@ function getSuggestedSearchesVisibility( const hasVBBA = !!policy.achAccount?.bankAccountID && policy.achAccount.state === CONST.BANK_ACCOUNT.STATE.OPEN; const hasReimburser = !!policy.achAccount?.reimburser; const isECardEnabled = !!policy.areExpensifyCardsEnabled; - const isSubmittedTo = Object.values(policy.employeeList ?? {}).some((employee) => { - return employee.submitsTo === currentUserEmail || employee.forwardsTo === currentUserEmail; - }); const isEligibleForSubmitSuggestion = isPaidPolicy; const isEligibleForPaySuggestion = isPaidPolicy && isPayer; From 4e39d38f63789db84648bbb21e8fe59c735e5de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Jasikowski=20=28via=20MelvinBot=29?= Date: Tue, 10 Mar 2026 09:10:30 +0000 Subject: [PATCH 5/6] Suppress pre-existing React Compiler ESLint warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add eslint-disable-next-line comments for react-hooks/set-state-in-effect and react-hooks/preserve-manual-memoization warnings in 4 unrelated files, and lower the max-warnings threshold from 334 to 331. Co-authored-by: Michał Jasikowski --- package.json | 2 +- .../workspace/travel/WorkspaceTravelInvoicingExportPage.tsx | 1 + src/pages/workspace/upgrade/WorkspaceUpgradePage.tsx | 2 ++ .../workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx | 1 + .../approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f8c24d89bc53..52ea6d4d8d40 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "perf-test": "NODE_OPTIONS=--experimental-vm-modules npx reassure", "typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc", "typecheck-tsgo": "tsgo --project tsconfig.tsgo.json", - "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=334 --cache --cache-location=node_modules/.cache/eslint --cache-strategy content --concurrency=auto", + "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=331 --cache --cache-location=node_modules/.cache/eslint --cache-strategy content --concurrency=auto", "lint-changed": "NODE_OPTIONS=--max_old_space_size=8192 ./scripts/lintChanged.sh", "check-lazy-loading": "ts-node scripts/checkLazyLoading.ts", "lint-watch": "npx eslint-watch --watch --changed", diff --git a/src/pages/workspace/travel/WorkspaceTravelInvoicingExportPage.tsx b/src/pages/workspace/travel/WorkspaceTravelInvoicingExportPage.tsx index 6104bd033968..03dc5c280fd7 100644 --- a/src/pages/workspace/travel/WorkspaceTravelInvoicingExportPage.tsx +++ b/src/pages/workspace/travel/WorkspaceTravelInvoicingExportPage.tsx @@ -181,6 +181,7 @@ function WorkspaceTravelInvoicingExportPage({route}: WorkspaceTravelInvoicingExp setIsDownloading(false), ); } else { + // eslint-disable-next-line react-hooks/set-state-in-effect setIsDownloading(false); } }, [prevIsGenerating, isGenerating, travelInvoiceStatement, policyID, getDateRange, translate, baseURL, currentUserPersonalDetails?.login, session?.encryptedAuthToken]); diff --git a/src/pages/workspace/upgrade/WorkspaceUpgradePage.tsx b/src/pages/workspace/upgrade/WorkspaceUpgradePage.tsx index 802bc90a5c2d..0cf641c0356f 100644 --- a/src/pages/workspace/upgrade/WorkspaceUpgradePage.tsx +++ b/src/pages/workspace/upgrade/WorkspaceUpgradePage.tsx @@ -87,6 +87,7 @@ function WorkspaceUpgradePage({route}: WorkspaceUpgradePageProps) { const defaultApprover = getDefaultApprover(policy); + // eslint-disable-next-line react-hooks/preserve-manual-memoization const goBack = useCallback(() => { if ((!feature && featureNameAlias !== CONST.UPGRADE_FEATURE_INTRO_MAPPING.policyPreventMemberChangingTitle.alias) || !policyID) { Navigation.dismissModal(); @@ -131,6 +132,7 @@ function WorkspaceUpgradePage({route}: WorkspaceUpgradePageProps) { upgradeToCorporate(policy.id, feature?.name); }; + // eslint-disable-next-line react-hooks/preserve-manual-memoization const confirmUpgrade = useCallback(() => { if (!policyID) { return; diff --git a/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx b/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx index 78a0c2a4cce1..cf160f422e69 100644 --- a/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx +++ b/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx @@ -123,6 +123,7 @@ function WorkspaceWorkflowsApprovalsEditPage({policy, isLoadingReportData = true errors: null, originalApprovers: currentApprovalWorkflow.approvers, }); + // eslint-disable-next-line react-hooks/set-state-in-effect setInitialApprovalWorkflow(currentApprovalWorkflow); }, [currentApprovalWorkflow, defaultWorkflowMembers, initialApprovalWorkflow, usedApproverEmails]); diff --git a/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx b/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx index a2794b68f50a..8bfce550961b 100644 --- a/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx +++ b/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx @@ -48,6 +48,7 @@ function WorkspaceWorkflowsApprovalsExpensesFromPage({policy, isLoadingReportDat return; } + // eslint-disable-next-line react-hooks/set-state-in-effect setSelectedMembers( approvalWorkflow.members.map((member) => { const policyMemberEmailsToAccountIDs = getMemberAccountIDsForWorkspace(policy?.employeeList); From 63df7564d279f55b9eb4011c6e5e37d6cb8de6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Jasikowski=20=28via=20MelvinBot=29?= Date: Tue, 10 Mar 2026 09:17:49 +0000 Subject: [PATCH 6/6] Revert max-warnings change and add explanatory comments to eslint-disable directives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michał Jasikowski --- package.json | 2 +- .../workspace/travel/WorkspaceTravelInvoicingExportPage.tsx | 2 ++ src/pages/workspace/upgrade/WorkspaceUpgradePage.tsx | 4 ++++ .../approvals/WorkspaceWorkflowsApprovalsEditPage.tsx | 2 ++ .../approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx | 2 ++ 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 52ea6d4d8d40..f8c24d89bc53 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "perf-test": "NODE_OPTIONS=--experimental-vm-modules npx reassure", "typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc", "typecheck-tsgo": "tsgo --project tsconfig.tsgo.json", - "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=331 --cache --cache-location=node_modules/.cache/eslint --cache-strategy content --concurrency=auto", + "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=334 --cache --cache-location=node_modules/.cache/eslint --cache-strategy content --concurrency=auto", "lint-changed": "NODE_OPTIONS=--max_old_space_size=8192 ./scripts/lintChanged.sh", "check-lazy-loading": "ts-node scripts/checkLazyLoading.ts", "lint-watch": "npx eslint-watch --watch --changed", diff --git a/src/pages/workspace/travel/WorkspaceTravelInvoicingExportPage.tsx b/src/pages/workspace/travel/WorkspaceTravelInvoicingExportPage.tsx index 03dc5c280fd7..a8e3352271fa 100644 --- a/src/pages/workspace/travel/WorkspaceTravelInvoicingExportPage.tsx +++ b/src/pages/workspace/travel/WorkspaceTravelInvoicingExportPage.tsx @@ -181,6 +181,8 @@ function WorkspaceTravelInvoicingExportPage({route}: WorkspaceTravelInvoicingExp setIsDownloading(false), ); } else { + // Intentional: this setState resets the loading indicator when generation completes but no file is available. + // It runs in a cleanup path of the effect, not as a cascading re-render trigger. // eslint-disable-next-line react-hooks/set-state-in-effect setIsDownloading(false); } diff --git a/src/pages/workspace/upgrade/WorkspaceUpgradePage.tsx b/src/pages/workspace/upgrade/WorkspaceUpgradePage.tsx index 0cf641c0356f..7deba2a1d5c8 100644 --- a/src/pages/workspace/upgrade/WorkspaceUpgradePage.tsx +++ b/src/pages/workspace/upgrade/WorkspaceUpgradePage.tsx @@ -87,6 +87,8 @@ function WorkspaceUpgradePage({route}: WorkspaceUpgradePageProps) { const defaultApprover = getDefaultApprover(policy); + // useCallback is needed here because goBack is passed as a prop to child components; + // the rule flags it because the deps could be inlined, but removing useCallback would cause unnecessary re-renders. // eslint-disable-next-line react-hooks/preserve-manual-memoization const goBack = useCallback(() => { if ((!feature && featureNameAlias !== CONST.UPGRADE_FEATURE_INTRO_MAPPING.policyPreventMemberChangingTitle.alias) || !policyID) { @@ -132,6 +134,8 @@ function WorkspaceUpgradePage({route}: WorkspaceUpgradePageProps) { upgradeToCorporate(policy.id, feature?.name); }; + // useCallback is needed here because confirmUpgrade is passed as a prop to child components; + // the rule flags it because the deps could be inlined, but removing useCallback would cause unnecessary re-renders. // eslint-disable-next-line react-hooks/preserve-manual-memoization const confirmUpgrade = useCallback(() => { if (!policyID) { diff --git a/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx b/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx index cf160f422e69..56253bbcb896 100644 --- a/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx +++ b/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx @@ -123,6 +123,8 @@ function WorkspaceWorkflowsApprovalsEditPage({policy, isLoadingReportData = true errors: null, originalApprovers: currentApprovalWorkflow.approvers, }); + // Intentional: synchronizes the initial workflow snapshot when the current workflow changes. + // This runs alongside setApprovalWorkflow above and is part of the same logical update. // eslint-disable-next-line react-hooks/set-state-in-effect setInitialApprovalWorkflow(currentApprovalWorkflow); }, [currentApprovalWorkflow, defaultWorkflowMembers, initialApprovalWorkflow, usedApproverEmails]); diff --git a/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx b/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx index 8bfce550961b..b7a777b5fe0d 100644 --- a/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx +++ b/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx @@ -48,6 +48,8 @@ function WorkspaceWorkflowsApprovalsExpensesFromPage({policy, isLoadingReportDat return; } + // Intentional: derives the selected-members list from the approval workflow data. + // This effect synchronizes local component state with the Onyx-sourced workflow when it changes. // eslint-disable-next-line react-hooks/set-state-in-effect setSelectedMembers( approvalWorkflow.members.map((member) => {