From 8a859845bed19fd04bcc209973646542faf39153 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 26 Nov 2026 18:06:38 +0700 Subject: [PATCH 1/4] Add Approve account merge requests task to Home --- src/CONST/SENTRY_LABEL.ts | 2 + src/ONYXKEYS.ts | 4 ++ src/languages/en.ts | 4 ++ src/languages/es.ts | 4 ++ src/pages/home/ForYouSection/index.tsx | 11 +++++ .../useApproveAccountMergeRequests.ts | 44 +++++++++++++++++++ src/selectors/Domain.ts | 32 +++++++++++++- .../onyx/DomainAccountMergeRequestSummary.ts | 7 +++ src/types/onyx/index.ts | 2 + tests/unit/DomainSelectorsTest.ts | 23 ++++++++++ 10 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 src/pages/home/ForYouSection/useApproveAccountMergeRequests.ts create mode 100644 src/types/onyx/DomainAccountMergeRequestSummary.ts diff --git a/src/CONST/SENTRY_LABEL.ts b/src/CONST/SENTRY_LABEL.ts index b052fa61e981..980cd2b45e55 100644 --- a/src/CONST/SENTRY_LABEL.ts +++ b/src/CONST/SENTRY_LABEL.ts @@ -1469,6 +1469,7 @@ const SENTRY_LABEL = { PAY: 'HomePage-ForYouItem-Pay', EXPORT: 'HomePage-ForYouItem-Export', REVIEW_DOMAIN_ADMIN_REQUESTS: 'HomePage-ForYouItem-ReviewDomainAdminRequests', + APPROVE_ACCOUNT_MERGE_REQUESTS: 'HomePage-ForYouItem-ApproveAccountMergeRequests', }, FOR_YOU_ITEM_BUTTON: { REVIEW_EXPENSES: 'HomePage-ForYouItemButton-ReviewExpenses', @@ -1477,6 +1478,7 @@ const SENTRY_LABEL = { PAY: 'HomePage-ForYouItemButton-Pay', EXPORT: 'HomePage-ForYouItemButton-Export', REVIEW_DOMAIN_ADMIN_REQUESTS: 'HomePage-ForYouItemButton-ReviewDomainAdminRequests', + APPROVE_ACCOUNT_MERGE_REQUESTS: 'HomePage-ForYouItemButton-ApproveAccountMergeRequests', }, TIME_SENSITIVE_ITEM: { ACTIVATE_CARD: 'HomePage-TimeSensitiveItem-ActivateCard', diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 3769b74e9699..52a80ccee1c9 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -294,6 +294,9 @@ const ONYXKEYS = { /** Whether the "For You" section has ever shown an actionable to-do (keeps the section visible once seen) */ NVP_HAS_SEEN_FOR_YOU_TODO: 'nvp_hasSeenForYouTodo', + /** Home-page summary of the pending account merge requests the current user can approve, grouped by target domain */ + DOMAIN_ACCOUNT_MERGE_REQUEST_SUMMARY: 'domainAccountMergeRequestSummary', + /** The insight the user last selected in the Home page insights card (defaults to Spend over time) */ NVP_HOME_SELECTED_INSIGHT: 'nvp_homeSelectedInsight', @@ -1993,6 +1996,7 @@ type OnyxValuesMapping = { [ONYXKEYS.OPTIMISTIC_AGENT_ACCOUNT_ID_MAPPING]: Record; [ONYXKEYS.HAS_LOADED_APP]: boolean; [ONYXKEYS.NVP_HAS_SEEN_FOR_YOU_TODO]: boolean; + [ONYXKEYS.DOMAIN_ACCOUNT_MERGE_REQUEST_SUMMARY]: OnyxTypes.DomainAccountMergeRequestSummary; [ONYXKEYS.NVP_HOME_SELECTED_INSIGHT]: | typeof CONST.SEARCH.SEARCH_KEYS.SPEND_OVER_TIME | typeof CONST.SEARCH.SEARCH_KEYS.TOP_SPENDERS diff --git a/src/languages/en.ts b/src/languages/en.ts index 3ae174d7b58f..1099b6a59473 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1294,6 +1294,10 @@ const translations = { one: 'Review 1 domain admin request', other: `Review ${count} domain admin requests`, }), + approveAccountMergeRequests: ({count}: {count: number}) => ({ + one: 'Approve 1 account merge request', + other: `Approve ${count} account merge requests`, + }), begin: 'Begin', emptyStateMessages: { thumbsUpStarsTitle: "You're done!", diff --git a/src/languages/es.ts b/src/languages/es.ts index 8750e6e31983..bb3ff05c7676 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1174,6 +1174,10 @@ const translations: TranslationDeepObject = { one: 'Revisa 1 solicitud de administrador de dominio', other: `Revisa ${count} solicitudes de administrador de dominio`, }), + approveAccountMergeRequests: ({count}: {count: number}) => ({ + one: 'Aprueba 1 solicitud de fusión de cuenta', + other: `Aprueba ${count} solicitudes de fusión de cuenta`, + }), }, gettingStartedSection: { title: 'Primeros pasos', diff --git a/src/pages/home/ForYouSection/index.tsx b/src/pages/home/ForYouSection/index.tsx index e91dc36b858c..5debb485cf78 100644 --- a/src/pages/home/ForYouSection/index.tsx +++ b/src/pages/home/ForYouSection/index.tsx @@ -27,6 +27,7 @@ import React, {useEffect} from 'react'; import ConciergePromptBox from './ConciergePromptBox'; import ForYouBody from './ForYouBody'; import shouldHideForYouSection from './shouldHideForYouSection'; +import useApproveAccountMergeRequests from './useApproveAccountMergeRequests'; import useReviewDomainAdminRequests from './useReviewDomainAdminRequests'; import useReviewFlaggedExpenses from './useReviewFlaggedExpenses'; @@ -52,6 +53,7 @@ function ForYouSection({isInitialLoad, isConciergeMenuVisible, setIsConciergeMen const [hasSeenForYouTodo = false] = useOnyx(ONYXKEYS.NVP_HAS_SEEN_FOR_YOU_TODO); const {count: flaggedExpensesCount, reviewExpenses} = useReviewFlaggedExpenses(); const {count: domainAdminRequestsCount, reviewDomainAdminRequests} = useReviewDomainAdminRequests(); + const {count: accountMergeRequestsCount, approveAccountMergeRequests} = useApproveAccountMergeRequests(); const timeSensitiveItems = useTimeSensitiveItems(); const icons = useMemoizedLazyExpensifyIcons(['ReceiptSearch', 'MoneyBag', 'Send', 'ThumbsUp', 'Export', 'UserShield']); @@ -158,6 +160,15 @@ function ForYouSection({isInitialLoad, isConciergeMenuVisible, setIsConciergeMen translationKey: 'homePage.forYouSection.reviewDomainAdminRequests' as const, handler: reviewDomainAdminRequests, }, + { + key: 'approveAccountMergeRequests', + sentryLabel: CONST.SENTRY_LABEL.HOME_PAGE.FOR_YOU_ITEM.APPROVE_ACCOUNT_MERGE_REQUESTS, + buttonSentryLabel: CONST.SENTRY_LABEL.HOME_PAGE.FOR_YOU_ITEM_BUTTON.APPROVE_ACCOUNT_MERGE_REQUESTS, + count: accountMergeRequestsCount, + icon: icons.UserShield, + translationKey: 'homePage.forYouSection.approveAccountMergeRequests' as const, + handler: approveAccountMergeRequests, + }, ].filter((item) => item.count > 0); const hasAnyTodos = todoItems.length > 0; diff --git a/src/pages/home/ForYouSection/useApproveAccountMergeRequests.ts b/src/pages/home/ForYouSection/useApproveAccountMergeRequests.ts new file mode 100644 index 000000000000..685cfa8e3ae1 --- /dev/null +++ b/src/pages/home/ForYouSection/useApproveAccountMergeRequests.ts @@ -0,0 +1,44 @@ +import useOnyx from '@hooks/useOnyx'; +import usePermissions from '@hooks/usePermissions'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; + +import navigateToDomainRouteWithSidebarSync from '@libs/Navigation/helpers/navigateToDomainRouteWithSidebarSync'; +import Navigation from '@libs/Navigation/Navigation'; + +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; +import {getPendingAccountMergeApprovals} from '@src/selectors/Domain'; + +type ApproveAccountMergeRequests = { + /** Number of pending account merge requests the current user can approve, used to decide whether to render the approval row */ + count: number; + + /** accountIDs of the domains that have at least one approvable request, used to count distinct marked domain rows */ + domainAccountIDs: number[]; + + /** Opens the domain members page for the one domain with pending requests, or the domains list when there are several. */ + approveAccountMergeRequests: () => void; +}; + +/** Handles the "Approve X account merge request(s)" row on the "For you" section of the home page. */ +function useApproveAccountMergeRequests(): ApproveAccountMergeRequests { + const {shouldUseNarrowLayout} = useResponsiveLayout(); + const {isBetaEnabled} = usePermissions(); + const [summary] = useOnyx(ONYXKEYS.DOMAIN_ACCOUNT_MERGE_REQUEST_SUMMARY); + + const {count, domainAccountIDs} = isBetaEnabled(CONST.BETAS.MERGE_DOMAIN_ACCOUNTS) ? getPendingAccountMergeApprovals(summary) : {count: 0, domainAccountIDs: []}; + + const approveAccountMergeRequests = () => { + const domainAccountID = domainAccountIDs.at(0); + if (domainAccountIDs.length === 1 && domainAccountID !== undefined) { + navigateToDomainRouteWithSidebarSync(ROUTES.DOMAIN_MEMBERS.getRoute(domainAccountID), domainAccountID, shouldUseNarrowLayout); + return; + } + Navigation.navigate(ROUTES.DOMAINS_LIST.getRoute()); + }; + + return {count, domainAccountIDs, approveAccountMergeRequests}; +} + +export default useApproveAccountMergeRequests; diff --git a/src/selectors/Domain.ts b/src/selectors/Domain.ts index 4ed0f6a56b06..095536b1f2f4 100644 --- a/src/selectors/Domain.ts +++ b/src/selectors/Domain.ts @@ -1,6 +1,6 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {CardFeeds, Domain, DomainErrors, DomainPendingActions, DomainSecurityGroup, DomainSettings, SamlMetadata} from '@src/types/onyx'; +import type {CardFeeds, Domain, DomainAccountMergeRequestSummary, DomainErrors, DomainPendingActions, DomainSecurityGroup, DomainSettings, SamlMetadata} from '@src/types/onyx'; import type {SecurityGroupKey, UserSecurityGroupData} from '@src/types/onyx/Domain'; import type {DomainSecurityGroupErrors} from '@src/types/onyx/DomainErrors'; import type {DomainSecurityGroupPendingActions} from '@src/types/onyx/DomainPendingActions'; @@ -300,6 +300,35 @@ function getPendingDomainAdminRequests( return count > 0 ? {count, domainAccountIDs} : EMPTY_PENDING_DOMAIN_ADMIN_REQUESTS; } +type PendingAccountMergeApprovals = { + /** Total pending account merge requests the current user can approve across every domain they administer */ + count: number; + /** accountIDs of the domains that contributed at least one pending request, for navigation and GBR indicators */ + domainAccountIDs: number[]; +}; + +const EMPTY_PENDING_ACCOUNT_MERGE_APPROVALS: PendingAccountMergeApprovals = {count: 0, domainAccountIDs: []}; + +/** Sums the authorized merge-approval counts from the Home summary and collects the domains that still have pending work. */ +function getPendingAccountMergeApprovals(summary: OnyxEntry): PendingAccountMergeApprovals { + const countByDomainAccountID = summary?.pendingApprovalCountByDomainAccountID; + if (!countByDomainAccountID) { + return EMPTY_PENDING_ACCOUNT_MERGE_APPROVALS; + } + + let count = 0; + const domainAccountIDs: number[] = []; + for (const [domainAccountID, pendingCount] of Object.entries(countByDomainAccountID)) { + if (pendingCount <= 0) { + continue; + } + count += pendingCount; + domainAccountIDs.push(Number(domainAccountID)); + } + + return count > 0 ? {count, domainAccountIDs} : EMPTY_PENDING_ACCOUNT_MERGE_APPROVALS; +} + /** Creates a selector that extracts the pending action for a security group's setting */ function domainSecurityGroupSettingPendingActionSelector(settingName: keyof DomainSecurityGroupPendingActions, groupID?: string) { return (domainPendingActions: OnyxEntry) => { @@ -347,6 +376,7 @@ export { pendingAdminRequesterAccountIDsSelector, adminshipRequesterPendingActionSelector, getPendingDomainAdminRequests, + getPendingAccountMergeApprovals, selectGroupByID, domainSecurityGroupSettingPendingActionSelector, domainSecurityGroupSettingErrorsSelector, diff --git a/src/types/onyx/DomainAccountMergeRequestSummary.ts b/src/types/onyx/DomainAccountMergeRequestSummary.ts new file mode 100644 index 000000000000..2f6c2d0b3da6 --- /dev/null +++ b/src/types/onyx/DomainAccountMergeRequestSummary.ts @@ -0,0 +1,7 @@ +/** Home-page summary of the pending account merge requests the current user is authorized to approve. */ +type DomainAccountMergeRequestSummary = { + /** Count of pending merge requests the current user can approve, keyed by the target domain's accountID. */ + pendingApprovalCountByDomainAccountID: Record; +}; + +export default DomainAccountMergeRequestSummary; diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index b6f090672c7a..0c98d0424d77 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -79,6 +79,7 @@ import type DismissedReferralBanners from './DismissedReferralBanners'; import type Domain from './Domain'; import type {DomainSecurityGroup, SamlMetadata, UserSecurityGroupData} from './Domain'; import type DomainAccountMergeRequest from './DomainAccountMergeRequest'; +import type DomainAccountMergeRequestSummary from './DomainAccountMergeRequestSummary'; import type DomainErrors from './DomainErrors'; import type DomainHighlightItems from './DomainHighlightItems'; import type DomainPendingActions from './DomainPendingActions'; @@ -566,6 +567,7 @@ export type { AppReviewLastPrompt, SamlMetadata, DomainAccountMergeRequest, + DomainAccountMergeRequestSummary, DomainErrors, DomainHighlightItems, DomainPendingActions, diff --git a/tests/unit/DomainSelectorsTest.ts b/tests/unit/DomainSelectorsTest.ts index 3e9b8c5a2ffa..3d2884ea7e75 100644 --- a/tests/unit/DomainSelectorsTest.ts +++ b/tests/unit/DomainSelectorsTest.ts @@ -10,6 +10,7 @@ import { adminAccountIDsSelector, adminPendingActionSelector, adminshipRequesterPendingActionSelector, + getPendingAccountMergeApprovals, getPendingDomainAdminRequests, defaultSecurityGroupIDSelector, domainEmailSelector, @@ -1102,4 +1103,26 @@ describe('domainSelectors', () => { expect(selectRestrictedPrimaryPolicyID('g2')(domain)).toBe('pB'); }); }); + + describe('getPendingAccountMergeApprovals', () => { + it('returns an empty result when the summary is missing', () => { + expect(getPendingAccountMergeApprovals(undefined)).toEqual({count: 0, domainAccountIDs: []}); + }); + + it('returns an empty result when no domain has approvable requests', () => { + expect(getPendingAccountMergeApprovals({pendingApprovalCountByDomainAccountID: {}})).toEqual({count: 0, domainAccountIDs: []}); + }); + + it('sums a single domain count', () => { + expect(getPendingAccountMergeApprovals({pendingApprovalCountByDomainAccountID: {'1': 2}})).toEqual({count: 2, domainAccountIDs: [1]}); + }); + + it('sums counts across domains and lists each affected domain once', () => { + expect(getPendingAccountMergeApprovals({pendingApprovalCountByDomainAccountID: {'1': 2, '2': 1}})).toEqual({count: 3, domainAccountIDs: [1, 2]}); + }); + + it('ignores non-positive counts', () => { + expect(getPendingAccountMergeApprovals({pendingApprovalCountByDomainAccountID: {'1': 0, '2': 1}})).toEqual({count: 1, domainAccountIDs: [2]}); + }); + }); }); From 8a314ae87ad7f66dae5db7b68b0f644dbc2cebfc Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 30 Nov 2026 14:36:18 +0700 Subject: [PATCH 2/4] drop domainAccountMergeRequestSummary key --- src/ONYXKEYS.ts | 9 +++---- .../useApproveAccountMergeRequests.ts | 4 +-- src/selectors/Domain.ts | 27 +++++++++++-------- .../onyx/DomainAccountMergeRequestSummary.ts | 7 ----- .../DomainAccountMergeRequestsToReview.ts | 6 +++++ src/types/onyx/index.ts | 4 +-- 6 files changed, 30 insertions(+), 27 deletions(-) delete mode 100644 src/types/onyx/DomainAccountMergeRequestSummary.ts create mode 100644 src/types/onyx/DomainAccountMergeRequestsToReview.ts diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 780295ebad69..6172e9ebfc9b 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -300,9 +300,6 @@ const ONYXKEYS = { /** Whether the "For You" section has ever shown an actionable to-do (keeps the section visible once seen) */ NVP_HAS_SEEN_FOR_YOU_TODO: 'nvp_hasSeenForYouTodo', - /** Home-page summary of the pending account merge requests the current user can approve, grouped by target domain */ - DOMAIN_ACCOUNT_MERGE_REQUEST_SUMMARY: 'domainAccountMergeRequestSummary', - /** The insight the user last selected in the Home page insights card (defaults to Spend over time) */ NVP_HOME_SELECTED_INSIGHT: 'nvp_homeSelectedInsight', @@ -1061,8 +1058,10 @@ const ONYXKEYS = { POLICY_MERGE_HR_INITIAL_SYNC_MODAL_SHOWN: 'policyMergeHRInitialSyncModalShown_', POLICY_MERGE_ATS_INITIAL_SYNC_MODAL_SHOWN: 'policyMergeATSInitialSyncModalShown_', - /** Pending domain-controlled account merge requests, keyed by requestID. Requesters see only their own entry; admins see what they are authorized to review. */ + /** The current user's own pending domain-controlled account merge request, keyed by requestID. */ DOMAIN_ACCOUNT_MERGE_REQUEST: 'domainAccountMergeRequest_', + /** Pending domain-controlled account merge requests the current user is authorized to review, keyed by the target domain's accountID. */ + DOMAIN_ACCOUNT_MERGE_REQUESTS_TO_REVIEW: 'domainAccountMergeRequestsToReview_', RULE: 'rules_', WORKSPACE_INVITE_MEMBERS_DRAFT: 'workspaceInviteMembersDraft_', WORKSPACE_INVITE_MESSAGE_DRAFT: 'workspaceInviteMessageDraft_', @@ -1814,6 +1813,7 @@ type OnyxCollectionValuesMapping = { [ONYXKEYS.COLLECTION.POLICY_MERGE_HR_INITIAL_SYNC_MODAL_SHOWN]: boolean; [ONYXKEYS.COLLECTION.POLICY_MERGE_ATS_INITIAL_SYNC_MODAL_SHOWN]: boolean; [ONYXKEYS.COLLECTION.DOMAIN_ACCOUNT_MERGE_REQUEST]: OnyxTypes.DomainAccountMergeRequest; + [ONYXKEYS.COLLECTION.DOMAIN_ACCOUNT_MERGE_REQUESTS_TO_REVIEW]: OnyxTypes.DomainAccountMergeRequestsToReview; [ONYXKEYS.COLLECTION.SNAPSHOT]: OnyxTypes.SearchResults; [ONYXKEYS.COLLECTION.INSIGHTS]: OnyxTypes.InsightsDashboard; [ONYXKEYS.COLLECTION.INSIGHTS_TAG_LEVELS]: OnyxTypes.InsightsResponseTagLevels; @@ -2020,7 +2020,6 @@ type OnyxValuesMapping = { [ONYXKEYS.OPTIMISTIC_AGENT_ACCOUNT_ID_MAPPING]: Record; [ONYXKEYS.HAS_LOADED_APP]: boolean; [ONYXKEYS.NVP_HAS_SEEN_FOR_YOU_TODO]: boolean; - [ONYXKEYS.DOMAIN_ACCOUNT_MERGE_REQUEST_SUMMARY]: OnyxTypes.DomainAccountMergeRequestSummary; [ONYXKEYS.NVP_HOME_SELECTED_INSIGHT]: | typeof CONST.SEARCH.SEARCH_KEYS.SPEND_OVER_TIME | typeof CONST.SEARCH.SEARCH_KEYS.TOP_SPENDERS diff --git a/src/pages/home/ForYouSection/useApproveAccountMergeRequests.ts b/src/pages/home/ForYouSection/useApproveAccountMergeRequests.ts index 685cfa8e3ae1..a978fef54b5a 100644 --- a/src/pages/home/ForYouSection/useApproveAccountMergeRequests.ts +++ b/src/pages/home/ForYouSection/useApproveAccountMergeRequests.ts @@ -25,9 +25,9 @@ type ApproveAccountMergeRequests = { function useApproveAccountMergeRequests(): ApproveAccountMergeRequests { const {shouldUseNarrowLayout} = useResponsiveLayout(); const {isBetaEnabled} = usePermissions(); - const [summary] = useOnyx(ONYXKEYS.DOMAIN_ACCOUNT_MERGE_REQUEST_SUMMARY); + const [reviewableMergeRequestsByDomain] = useOnyx(ONYXKEYS.COLLECTION.DOMAIN_ACCOUNT_MERGE_REQUESTS_TO_REVIEW); - const {count, domainAccountIDs} = isBetaEnabled(CONST.BETAS.MERGE_DOMAIN_ACCOUNTS) ? getPendingAccountMergeApprovals(summary) : {count: 0, domainAccountIDs: []}; + const {count, domainAccountIDs} = isBetaEnabled(CONST.BETAS.MERGE_DOMAIN_ACCOUNTS) ? getPendingAccountMergeApprovals(reviewableMergeRequestsByDomain) : {count: 0, domainAccountIDs: []}; const approveAccountMergeRequests = () => { const domainAccountID = domainAccountIDs.at(0); diff --git a/src/selectors/Domain.ts b/src/selectors/Domain.ts index d44e4ee0462a..199cd38ca108 100644 --- a/src/selectors/Domain.ts +++ b/src/selectors/Domain.ts @@ -4,7 +4,7 @@ import type { CardFeeds, Domain, DomainAccountMergeRequest, - DomainAccountMergeRequestSummary, + DomainAccountMergeRequestsToReview, DomainErrors, DomainPendingActions, DomainSecurityGroup, @@ -319,24 +319,29 @@ type PendingAccountMergeApprovals = { const EMPTY_PENDING_ACCOUNT_MERGE_APPROVALS: PendingAccountMergeApprovals = {count: 0, domainAccountIDs: []}; -/** Sums the authorized merge-approval counts from the Home summary and collects the domains that still have pending work. */ -function getPendingAccountMergeApprovals(summary: OnyxEntry): PendingAccountMergeApprovals { - const countByDomainAccountID = summary?.pendingApprovalCountByDomainAccountID; - if (!countByDomainAccountID) { +/** Counts the merge requests the current user can review (approve or deny) from the collection the backend hydrates, and collects their distinct target domains. */ +function getPendingAccountMergeApprovals(reviewableMergeRequestsByDomain: OnyxCollection): PendingAccountMergeApprovals { + if (!reviewableMergeRequestsByDomain) { return EMPTY_PENDING_ACCOUNT_MERGE_APPROVALS; } let count = 0; - const domainAccountIDs: number[] = []; - for (const [domainAccountID, pendingCount] of Object.entries(countByDomainAccountID)) { - if (pendingCount <= 0) { + const domainAccountIDs = new Set(); + for (const [key, domainRequests] of Object.entries(reviewableMergeRequestsByDomain)) { + if (!domainRequests) { continue; } - count += pendingCount; - domainAccountIDs.push(Number(domainAccountID)); + + const domainCount = Object.values(domainRequests).filter((record) => !!record).length; + if (domainCount === 0) { + continue; + } + + count += domainCount; + domainAccountIDs.add(Number(key.replace(ONYXKEYS.COLLECTION.DOMAIN_ACCOUNT_MERGE_REQUESTS_TO_REVIEW, ''))); } - return count > 0 ? {count, domainAccountIDs} : EMPTY_PENDING_ACCOUNT_MERGE_APPROVALS; + return count > 0 ? {count, domainAccountIDs: [...domainAccountIDs]} : EMPTY_PENDING_ACCOUNT_MERGE_APPROVALS; } /** Creates a selector that extracts the pending action for a security group's setting */ diff --git a/src/types/onyx/DomainAccountMergeRequestSummary.ts b/src/types/onyx/DomainAccountMergeRequestSummary.ts deleted file mode 100644 index 2f6c2d0b3da6..000000000000 --- a/src/types/onyx/DomainAccountMergeRequestSummary.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** Home-page summary of the pending account merge requests the current user is authorized to approve. */ -type DomainAccountMergeRequestSummary = { - /** Count of pending merge requests the current user can approve, keyed by the target domain's accountID. */ - pendingApprovalCountByDomainAccountID: Record; -}; - -export default DomainAccountMergeRequestSummary; diff --git a/src/types/onyx/DomainAccountMergeRequestsToReview.ts b/src/types/onyx/DomainAccountMergeRequestsToReview.ts new file mode 100644 index 000000000000..13c3ced7c553 --- /dev/null +++ b/src/types/onyx/DomainAccountMergeRequestsToReview.ts @@ -0,0 +1,6 @@ +import type DomainAccountMergeRequest from './DomainAccountMergeRequest'; + +/** The merge requests the current user is authorized to review on one domain, keyed by requestID. */ +type DomainAccountMergeRequestsToReview = Record; + +export default DomainAccountMergeRequestsToReview; diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index 9940623a2049..70870221e5ca 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -79,7 +79,7 @@ import type DismissedReferralBanners from './DismissedReferralBanners'; import type Domain from './Domain'; import type {DomainSecurityGroup, SamlMetadata, UserSecurityGroupData} from './Domain'; import type DomainAccountMergeRequest from './DomainAccountMergeRequest'; -import type DomainAccountMergeRequestSummary from './DomainAccountMergeRequestSummary'; +import type DomainAccountMergeRequestsToReview from './DomainAccountMergeRequestsToReview'; import type DomainErrors from './DomainErrors'; import type DomainHighlightItems from './DomainHighlightItems'; import type DomainPendingActions from './DomainPendingActions'; @@ -318,6 +318,7 @@ export type { DismissedReferralBanners, Domain, DomainAccountMergeRequest, + DomainAccountMergeRequestsToReview, Download, ExportDownload, BulkAction, @@ -575,7 +576,6 @@ export type { AppReview, AppReviewLastPrompt, SamlMetadata, - DomainAccountMergeRequestSummary, DomainErrors, DomainHighlightItems, DomainPendingActions, From 3be126e02b4c26156bae58f3f1af0c6702a1ace6 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 1 Dec 2026 10:56:30 +0700 Subject: [PATCH 3/4] lint fix --- .../isDeployChecklistLocked/index.js | 52 ++++++------------- .../javascript/proposalPoliceComment/index.js | 52 ++++++------------- src/languages/de.ts | 4 ++ src/languages/el.ts | 4 ++ src/languages/fr.ts | 4 ++ src/languages/it.ts | 4 ++ src/languages/ja.ts | 4 ++ src/languages/nl.ts | 4 ++ src/languages/pl.ts | 6 +++ src/languages/pt-BR.ts | 4 ++ src/languages/zh-hans.ts | 4 ++ src/libs/ExportOnyxState/masking.ts | 1 + tests/unit/DomainSelectorsTest.ts | 47 ++++++++++++++--- 13 files changed, 114 insertions(+), 76 deletions(-) diff --git a/.github/actions/javascript/isDeployChecklistLocked/index.js b/.github/actions/javascript/isDeployChecklistLocked/index.js index dbd80a2f5293..27f6d2573fff 100644 --- a/.github/actions/javascript/isDeployChecklistLocked/index.js +++ b/.github/actions/javascript/isDeployChecklistLocked/index.js @@ -1886,16 +1886,6 @@ var require_API = __commonJS({ const newParameters = Object.assign(Object.assign({}, parameters), { api_setCookie: false }); return performPOSTRequest(commandName, newParameters); }, - /** - * @param {Object} parameters - * @param {String} parameters.email - * @returns {ExpensifyAPIDeferred} - */ - Domain_RequestAccess(parameters) { - const commandName = "Domain_RequestAccess"; - requireParameters(["email"], parameters, commandName); - return performPOSTRequest(commandName, parameters); - }, /** * @param {Object} parameters * @param {String[]} parameters.emailList @@ -21659,27 +21649,22 @@ var require_Network = __commonJS({ exports.default = Network; var jquery_1 = __importDefault(require_jquery()); var Utils = __importStar(require_utils()); - function addCommandToUrl(command, url) { - let newUrl = url; - if (command) { - if (newUrl.indexOf("?") === -1) { - newUrl = `${newUrl}?`; - } - newUrl = `${newUrl}&command=${command}`; - } - return newUrl; - } function Network(endpoint2) { let isNavigatingAway = false; - const isNewURLFormat = endpoint2[endpoint2.length - 1] === "/"; if (!endpoint2) { throw new Error("Cannot instantiate Network without an url endpoint"); } + const baseURL = endpoint2.endsWith("/") ? endpoint2 : `${endpoint2}/`; if (Utils.isWindowAvailable()) { window.onbeforeunload = () => { isNavigatingAway = true; }; } + function getRequestURL(parameters) { + const command = parameters.command; + delete parameters.command; + return command ? `${baseURL}${command}` : baseURL; + } return { /** * @param {String} url to fetch @@ -21694,20 +21679,13 @@ var require_Network = __commonJS({ * @returns {$.Deferred} */ post(parameters) { - let newURL = endpoint2; - if (isNewURLFormat) { - const command = parameters.command; - delete parameters.command; - newURL = `${endpoint2}${command}`; - } const settings = { - url: newURL, + url: getRequestURL(parameters), type: "POST", data: parameters }; const formData = new FormData(); let shouldUseFormData = false; - settings.url = addCommandToUrl(parameters.command, settings.url); for (const [key, value] of Object.entries(parameters)) { if (value === void 0) { continue; @@ -21741,8 +21719,7 @@ var require_Network = __commonJS({ keepalive: true, credentials: "same-origin" }; - let url = endpoint2; - url = addCommandToUrl(parameters.command, url); + const url = getRequestURL(parameters); const formData = new FormData(); for (const [key, value] of Object.entries(parameters)) { if (value === void 0) { @@ -22316,8 +22293,10 @@ var require_str = __commonJS({ * @returns The decoded string. */ htmlDecodeWithJQueryOrNative(s) { - if (typeof jquery_1.default !== "undefined") { - return (0, jquery_1.default)("