Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4347,7 +4347,7 @@ function createTypeMenuSections(params: TypeMenuSectionsParams): SearchTypeMenuS

const insightsSearchKeys = [
CONST.SEARCH.SEARCH_KEYS.SPEND_OVER_TIME,
...(!isTrackIntentUser ? [CONST.SEARCH.SEARCH_KEYS.TOP_SPENDERS] : []),
CONST.SEARCH.SEARCH_KEYS.TOP_SPENDERS,
CONST.SEARCH.SEARCH_KEYS.TOP_CATEGORIES,
CONST.SEARCH.SEARCH_KEYS.TOP_MERCHANTS,
];
Expand Down
45 changes: 45 additions & 0 deletions tests/unit/Search/SearchUIUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6999,6 +6999,51 @@ describe('SearchUIUtils', () => {
expect(allKeys).not.toContain(CONST.SEARCH.SEARCH_KEYS.EXPORT);
});

it('should show top spenders for track-intent users on eligible paid workspace', () => {
const mockPolicies = {
policy1: {
id: 'policy1',
name: 'Test Policy',
owner: adminEmail,
outputCurrency: 'USD',
isPolicyExpenseChatEnabled: true,
role: CONST.POLICY.ROLE.ADMIN,
type: CONST.POLICY.TYPE.TEAM,
employeeList: {
[adminEmail]: {
email: adminEmail,
role: CONST.POLICY.ROLE.ADMIN,
submitsTo: approverEmail,
},
[approverEmail]: {
email: approverEmail,
role: CONST.POLICY.ROLE.USER,
submitsTo: adminEmail,
},
},
},
};

const sections = SearchUIUtils.createTypeMenuSections({
currentUserEmail: adminEmail,
currentUserAccountID: adminAccountID,
cardFeedsByPolicy: {},
defaultCardFeed: undefined,
policies: mockPolicies,
savedSearches: {},
isOffline: false,
defaultExpensifyCard: undefined,
shouldRedirectToExpensifyClassic: false,
draftTransactionIDs: [],
isTrackIntentUser: true,
});

const allMenuItems = sections.flatMap((section) => section.menuItems);
const allKeys = allMenuItems.map((item) => item.key);

expect(allKeys).toContain(CONST.SEARCH.SEARCH_KEYS.TOP_SPENDERS);
});

it('should generate correct routes', () => {
const menuItems = SearchUIUtils.createTypeMenuSections({
currentUserEmail: undefined,
Expand Down
Loading