Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
098da9c
feat: add SearchFiltersTypePage
sofi-a Jun 1, 2025
8228183
feat: add SearchFiltersStatusPage
sofi-a Jun 1, 2025
1a78a00
feat: add type and status filter routes and screens
sofi-a Jun 1, 2025
740fa6b
feat: add type and status filters to advanced search filters
sofi-a Jun 1, 2025
13229d3
fix: translation typo
sofi-a Jun 2, 2025
e87477d
Merge branch 'main' into feat/add-status-and-type-filters-to-filters-…
sofi-a Jun 9, 2025
25ca7da
refactor: move status and type options to SearchUIUtils
sofi-a Jun 10, 2025
b85d41d
refactor: integrate getStatusOptions and getTypeOptions in type and s…
sofi-a Jun 10, 2025
bd7b88d
fix: sorting logic for section items in AdvancedSearchFilters
sofi-a Jun 10, 2025
9bac8ab
fix: empty type and status filter options on native platforms
sofi-a Jun 11, 2025
1e62319
fix: improve status filter display title
sofi-a Jun 11, 2025
cda56a9
fix: update getTypeOptions to accept session and policies data instea…
sofi-a Jun 11, 2025
712171d
fix: update status check to use constant for default value
sofi-a Jun 11, 2025
029a0d0
fix: reset logic for status and groupBy filters when type filter changes
sofi-a Jun 11, 2025
b21d74d
fix: improved parameter identifier for updateSelectedItems function
sofi-a Jun 11, 2025
90f8eca
fix: add 'all' option to status filter display title
sofi-a Jun 11, 2025
5004db6
fix: replace hardcoded 'type' key with constant in sorting logic
sofi-a Jun 11, 2025
7cf2490
refactor: conditionally include invoice option to type options based …
sofi-a Jun 11, 2025
c3379d3
fix: update ListItem type to enforce react keys
sofi-a Jun 13, 2025
8544151
fix: status filter assignment logic in buildFilterFormValuesFromQuery…
sofi-a Jun 13, 2025
a8bf795
Revert "refactor: conditionally include invoice option to type option…
sofi-a Jun 15, 2025
7a463af
Merge branch 'main' into feat/add-status-and-type-filters-to-filters-…
sofi-a Jun 15, 2025
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: 2 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6643,6 +6643,8 @@ const CONST = {
GROUP_BY: 'groupBy',
},
SYNTAX_FILTER_KEYS: {
TYPE: 'type',
STATUS: 'status',
DATE: 'date',
AMOUNT: 'amount',
EXPENSE_TYPE: 'expenseType',
Expand Down
2 changes: 2 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ const ROUTES = {
getRoute: ({name, jsonQuery}: {name: string; jsonQuery: SearchQueryString}) => `search/saved-search/rename?name=${name}&q=${jsonQuery}` as const,
},
SEARCH_ADVANCED_FILTERS: 'search/filters',
SEARCH_ADVANCED_FILTERS_TYPE: 'search/filters/type',
SEARCH_ADVANCED_FILTERS_STATUS: 'search/filters/status',
SEARCH_ADVANCED_FILTERS_DATE: 'search/filters/date',
SEARCH_ADVANCED_FILTERS_CURRENCY: 'search/filters/currency',
SEARCH_ADVANCED_FILTERS_MERCHANT: 'search/filters/merchant',
Expand Down
2 changes: 2 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const SCREENS = {
MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS: 'Search_Money_Request_Report_Hold_Transactions',
REPORT_RHP: 'Search_Report_RHP',
ADVANCED_FILTERS_RHP: 'Search_Advanced_Filters_RHP',
ADVANCED_FILTERS_TYPE_RHP: 'Search_Advanced_Filters_Type_RHP',
ADVANCED_FILTERS_STATUS_RHP: 'Search_Advanced_Filters_Status_RHP',
ADVANCED_FILTERS_DATE_RHP: 'Search_Advanced_Filters_Date_RHP',
ADVANCED_FILTERS_SUBMITTED_RHP: 'Search_Advanced_Filters_Submitted_RHP',
ADVANCED_FILTERS_APPROVED_RHP: 'Search_Advanced_Filters_Approved_RHP',
Expand Down
85 changes: 9 additions & 76 deletions src/components/Search/SearchPageHeader/SearchFiltersBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type {SingleSelectItem} from '@components/Search/FilterDropdowns/SingleSe
import SingleSelectPopup from '@components/Search/FilterDropdowns/SingleSelectPopup';
import UserSelectPopup from '@components/Search/FilterDropdowns/UserSelectPopup';
import {useSearchContext} from '@components/Search/SearchContext';
import type {SearchGroupBy, SearchQueryJSON, SingularSearchStatus} from '@components/Search/types';
import type {SearchQueryJSON, SingularSearchStatus} from '@components/Search/types';
import SearchFiltersSkeleton from '@components/Skeletons/SearchFiltersSkeleton';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
Expand All @@ -30,9 +30,9 @@ import {updateAdvancedFilters} from '@libs/actions/Search';
import {mergeCardListWithWorkspaceFeeds} from '@libs/CardUtils';
import DateUtils from '@libs/DateUtils';
import Navigation from '@libs/Navigation/Navigation';
import {canSendInvoice, getAllTaxRates} from '@libs/PolicyUtils';
import {hasInvoiceReports} from '@libs/ReportUtils';
import {getAllTaxRates} from '@libs/PolicyUtils';
import {buildFilterFormValuesFromQuery, buildQueryStringFromFilterFormValues, buildSearchQueryJSON, buildSearchQueryString} from '@libs/SearchQueryUtils';
import {getStatusOptions, getTypeOptions} from '@libs/SearchUIUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand All @@ -44,70 +44,6 @@ type SearchFiltersBarProps = {
headerButtonsOptions: Array<DropdownOption<SearchHeaderOptionValue>>;
};

const typeOptions: Array<SingleSelectItem<SearchDataTypes>> = [
{translation: 'common.expense', value: CONST.SEARCH.DATA_TYPES.EXPENSE},
{translation: 'common.chat', value: CONST.SEARCH.DATA_TYPES.CHAT},
{translation: 'common.invoice', value: CONST.SEARCH.DATA_TYPES.INVOICE},
{translation: 'common.trip', value: CONST.SEARCH.DATA_TYPES.TRIP},
{translation: 'common.task', value: CONST.SEARCH.DATA_TYPES.TASK},
];

const expenseStatusOptions: Array<MultiSelectItem<SingularSearchStatus>> = [
{translation: 'common.unreported', value: CONST.SEARCH.STATUS.EXPENSE.UNREPORTED},
{translation: 'common.drafts', value: CONST.SEARCH.STATUS.EXPENSE.DRAFTS},
{translation: 'common.outstanding', value: CONST.SEARCH.STATUS.EXPENSE.OUTSTANDING},
{translation: 'iou.approved', value: CONST.SEARCH.STATUS.EXPENSE.APPROVED},
{translation: 'iou.settledExpensify', value: CONST.SEARCH.STATUS.EXPENSE.PAID},
{translation: 'iou.done', value: CONST.SEARCH.STATUS.EXPENSE.DONE},
];

const expenseReportStatusOptions: Array<MultiSelectItem<SingularSearchStatus>> = [
{translation: 'common.drafts', value: CONST.SEARCH.STATUS.EXPENSE.DRAFTS},
{translation: 'common.outstanding', value: CONST.SEARCH.STATUS.EXPENSE.OUTSTANDING},
{translation: 'iou.approved', value: CONST.SEARCH.STATUS.EXPENSE.APPROVED},
{translation: 'iou.settledExpensify', value: CONST.SEARCH.STATUS.EXPENSE.PAID},
{translation: 'iou.done', value: CONST.SEARCH.STATUS.EXPENSE.DONE},
];

const chatStatusOptions: Array<MultiSelectItem<SingularSearchStatus>> = [
{translation: 'common.unread', value: CONST.SEARCH.STATUS.CHAT.UNREAD},
{translation: 'common.sent', value: CONST.SEARCH.STATUS.CHAT.SENT},
{translation: 'common.attachments', value: CONST.SEARCH.STATUS.CHAT.ATTACHMENTS},
{translation: 'common.links', value: CONST.SEARCH.STATUS.CHAT.LINKS},
{translation: 'search.filters.pinned', value: CONST.SEARCH.STATUS.CHAT.PINNED},
];

const invoiceStatusOptions: Array<MultiSelectItem<SingularSearchStatus>> = [
{translation: 'common.outstanding', value: CONST.SEARCH.STATUS.INVOICE.OUTSTANDING},
{translation: 'iou.settledExpensify', value: CONST.SEARCH.STATUS.INVOICE.PAID},
];

const tripStatusOptions: Array<MultiSelectItem<SingularSearchStatus>> = [
{translation: 'search.filters.current', value: CONST.SEARCH.STATUS.TRIP.CURRENT},
{translation: 'search.filters.past', value: CONST.SEARCH.STATUS.TRIP.PAST},
];

const taskStatusOptions: Array<MultiSelectItem<SingularSearchStatus>> = [
{translation: 'common.outstanding', value: CONST.SEARCH.STATUS.TASK.OUTSTANDING},
{translation: 'search.filters.completed', value: CONST.SEARCH.STATUS.TASK.COMPLETED},
];

function getStatusOptions(type: SearchDataTypes, groupBy: SearchGroupBy | undefined) {
switch (type) {
case CONST.SEARCH.DATA_TYPES.CHAT:
return chatStatusOptions;
case CONST.SEARCH.DATA_TYPES.INVOICE:
return invoiceStatusOptions;
case CONST.SEARCH.DATA_TYPES.TRIP:
return tripStatusOptions;
case CONST.SEARCH.DATA_TYPES.TASK:
return taskStatusOptions;
case CONST.SEARCH.DATA_TYPES.EXPENSE:
default:
return groupBy === CONST.SEARCH.GROUP_BY.REPORTS ? expenseReportStatusOptions : expenseStatusOptions;
}
}

function SearchFiltersBar({queryJSON, headerButtonsOptions}: SearchFiltersBarProps) {
const {hash, type, groupBy, status} = queryJSON;
const scrollRef = useRef<RNScrollView>(null);
Expand Down Expand Up @@ -139,6 +75,8 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions}: SearchFiltersBarPro
const hasErrors = Object.keys(currentSearchResults?.errors ?? {}).length > 0 && !isOffline;
const shouldShowSelectedDropdown = headerButtonsOptions.length > 0 && (!shouldUseNarrowLayout || (!!selectionMode && selectionMode.isEnabled));

const typeOptions = useMemo(() => getTypeOptions(allPolicies, session?.email), [allPolicies, session?.email]);

const filterFormValues = useMemo(() => {
return buildFilterFormValuesFromQuery(queryJSON, policyCategories, policyTagsLists, currencyList, personalDetails, allCards, reports, taxRates);
}, [allCards, currencyList, personalDetails, policyCategories, policyTagsLists, queryJSON, reports, taxRates]);
Expand Down Expand Up @@ -171,23 +109,17 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions}: SearchFiltersBarPro
Navigation.setParams({q: query});
};

// Remove the invoice option if the user is not allowed to send invoices
let visibleOptions = typeOptions;
if (!canSendInvoice(allPolicies, session?.email) && !hasInvoiceReports()) {
visibleOptions = visibleOptions.filter((typeOption) => typeOption.value !== CONST.SEARCH.DATA_TYPES.INVOICE);
}

return (
<SingleSelectPopup
label={translate('common.type')}
value={value}
items={visibleOptions}
items={typeOptions}
closeOverlay={closeOverlay}
onChange={onChange}
/>
);
},
[allPolicies, groupBy, queryJSON, session?.email, status, translate, type],
[groupBy, queryJSON, status, translate, type, typeOptions],
);

const statusComponent = useCallback(
Expand Down Expand Up @@ -314,12 +246,13 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions}: SearchFiltersBarPro

return filterList;
}, [
typeOptions,
type,
groupBy,
filterFormValues.from,
filterFormValues.dateAfter,
filterFormValues.dateBefore,
filterFormValues.dateOn,
filterFormValues.from,
translate,
typeComponent,
statusComponent,
Expand Down
4 changes: 2 additions & 2 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ type ExtendedTargetedEvent = TargetedEvent & {
};
};

type ListItem = {
type ListItem<K extends string | number = string> = {
/** Text to display */
text?: string;

/** Alternate text to display */
alternateText?: string | null;

/** Key used internally by React */
keyForList?: string | null;
keyForList?: K | null;

/** Whether this option is selected */
isSelected?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,8 @@ const SearchReportModalStackNavigator = createModalStackNavigator<SearchReportPa

const SearchAdvancedFiltersModalStackNavigator = createModalStackNavigator<SearchAdvancedFiltersParamList>({
[SCREENS.SEARCH.ADVANCED_FILTERS_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_TYPE_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage/SearchFiltersTypePage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_STATUS_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage/SearchFiltersStatusPage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_DATE_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage/SearchFiltersDatePage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_SUBMITTED_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage/SearchFiltersSubmittedPage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_APPROVED_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage/SearchFiltersApprovedPage').default,
Expand Down
2 changes: 2 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,8 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
[SCREENS.RIGHT_MODAL.SEARCH_ADVANCED_FILTERS]: {
screens: {
[SCREENS.SEARCH.ADVANCED_FILTERS_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS,
[SCREENS.SEARCH.ADVANCED_FILTERS_TYPE_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_TYPE,
[SCREENS.SEARCH.ADVANCED_FILTERS_STATUS_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_STATUS,
[SCREENS.SEARCH.ADVANCED_FILTERS_DATE_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_DATE,
[SCREENS.SEARCH.ADVANCED_FILTERS_SUBMITTED_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_SUBMITTED,
[SCREENS.SEARCH.ADVANCED_FILTERS_APPROVED_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_APPROVED,
Expand Down
20 changes: 13 additions & 7 deletions src/libs/SearchQueryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,15 +572,21 @@ function buildFilterFormValuesFromQuery(
}
}

const [typeKey = '', typeValue] = Object.entries(CONST.SEARCH.DATA_TYPES).find(([, value]) => value === queryJSON.type) ?? [];
const [typeKey, typeValue] = Object.entries(CONST.SEARCH.DATA_TYPES).find(([, value]) => value === queryJSON.type) ?? [];
filtersForm[FILTER_KEYS.TYPE] = typeValue ? queryJSON.type : CONST.SEARCH.DATA_TYPES.EXPENSE;
const [statusKey] =
Object.entries(CONST.SEARCH.STATUS).find(([, value]) =>
Array.isArray(queryJSON.status) ? queryJSON.status.some((status) => Object.values(value).includes(status)) : Object.values(value).includes(queryJSON.status),
) ?? [];

if (typeKey === statusKey) {
filtersForm[FILTER_KEYS.STATUS] = Array.isArray(queryJSON.status) ? queryJSON.status.join(',') : queryJSON.status;
if (typeKey) {
if (Array.isArray(queryJSON.status)) {
const validStatuses = queryJSON.status.filter((status) => Object.values(CONST.SEARCH.STATUS[typeKey as keyof typeof CONST.SEARCH.DATA_TYPES]).includes(status));

if (validStatuses.length) {
filtersForm[FILTER_KEYS.STATUS] = queryJSON.status.join(',');
} else {
filtersForm[FILTER_KEYS.STATUS] = CONST.SEARCH.STATUS.EXPENSE.ALL;
}
} else {
filtersForm[FILTER_KEYS.STATUS] = queryJSON.status;
}
} else {
filtersForm[FILTER_KEYS.STATUS] = CONST.SEARCH.STATUS.EXPENSE.ALL;
}
Expand Down
79 changes: 77 additions & 2 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import type {ValueOf} from 'type-fest';
import DotLottieAnimations from '@components/LottieAnimations';
import type DotLottieAnimation from '@components/LottieAnimations/types';
import type {MenuItemWithLink} from '@components/MenuItemList';
import type {SearchColumnType, SearchQueryJSON, SearchQueryString, SearchStatus, SortOrder} from '@components/Search/types';
import type {MultiSelectItem} from '@components/Search/FilterDropdowns/MultiSelectPopup';
import type {SingleSelectItem} from '@components/Search/FilterDropdowns/SingleSelectPopup';
import type {SearchColumnType, SearchGroupBy, SearchQueryJSON, SearchQueryString, SearchStatus, SingularSearchStatus, SortOrder} from '@components/Search/types';
import ChatListItem from '@components/SelectionList/ChatListItem';
import ReportListItem from '@components/SelectionList/Search/ReportListItem';
import TaskListItem from '@components/SelectionList/Search/TaskListItem';
Expand Down Expand Up @@ -41,14 +43,15 @@ import {translateLocal} from './Localize';
import Navigation from './Navigation/Navigation';
import Parser from './Parser';
import {getDisplayNameOrDefault} from './PersonalDetailsUtils';
import {getActivePolicy, getGroupPaidPoliciesWithExpenseChatEnabled, getPolicy, isPaidGroupPolicy} from './PolicyUtils';
import {canSendInvoice, getActivePolicy, getGroupPaidPoliciesWithExpenseChatEnabled, getPolicy, isPaidGroupPolicy} from './PolicyUtils';
import {getOriginalMessage, isCreatedAction, isDeletedAction, isMoneyRequestAction, isResolvedActionableWhisper, isWhisperActionTargetedToOthers} from './ReportActionsUtils';
import {
getIcons,
getPersonalDetailsForAccountID,
getReportName,
getReportOrDraftReport,
getSearchReportName,
hasInvoiceReports,
hasOnlyHeldExpenses,
hasViolations,
isAllowedToApproveExpenseReport as isAllowedToApproveExpenseReportUtils,
Expand Down Expand Up @@ -97,6 +100,46 @@ const taskColumnNamesToSortingProperty = {
[CONST.SEARCH.TABLE_COLUMNS.IN]: 'parentReportID' as const,
};

const expenseStatusOptions: Array<MultiSelectItem<SingularSearchStatus>> = [
{translation: 'common.unreported', value: CONST.SEARCH.STATUS.EXPENSE.UNREPORTED},
{translation: 'common.drafts', value: CONST.SEARCH.STATUS.EXPENSE.DRAFTS},
{translation: 'common.outstanding', value: CONST.SEARCH.STATUS.EXPENSE.OUTSTANDING},
{translation: 'iou.approved', value: CONST.SEARCH.STATUS.EXPENSE.APPROVED},
{translation: 'iou.settledExpensify', value: CONST.SEARCH.STATUS.EXPENSE.PAID},
{translation: 'iou.done', value: CONST.SEARCH.STATUS.EXPENSE.DONE},
];

const expenseReportStatusOptions: Array<MultiSelectItem<SingularSearchStatus>> = [
{translation: 'common.drafts', value: CONST.SEARCH.STATUS.EXPENSE.DRAFTS},
{translation: 'common.outstanding', value: CONST.SEARCH.STATUS.EXPENSE.OUTSTANDING},
{translation: 'iou.approved', value: CONST.SEARCH.STATUS.EXPENSE.APPROVED},
{translation: 'iou.settledExpensify', value: CONST.SEARCH.STATUS.EXPENSE.PAID},
{translation: 'iou.done', value: CONST.SEARCH.STATUS.EXPENSE.DONE},
];

const chatStatusOptions: Array<MultiSelectItem<SingularSearchStatus>> = [
{translation: 'common.unread', value: CONST.SEARCH.STATUS.CHAT.UNREAD},
{translation: 'common.sent', value: CONST.SEARCH.STATUS.CHAT.SENT},
{translation: 'common.attachments', value: CONST.SEARCH.STATUS.CHAT.ATTACHMENTS},
{translation: 'common.links', value: CONST.SEARCH.STATUS.CHAT.LINKS},
{translation: 'search.filters.pinned', value: CONST.SEARCH.STATUS.CHAT.PINNED},
];

const invoiceStatusOptions: Array<MultiSelectItem<SingularSearchStatus>> = [
{translation: 'common.outstanding', value: CONST.SEARCH.STATUS.INVOICE.OUTSTANDING},
{translation: 'iou.settledExpensify', value: CONST.SEARCH.STATUS.INVOICE.PAID},
];

const tripStatusOptions: Array<MultiSelectItem<SingularSearchStatus>> = [
{translation: 'search.filters.current', value: CONST.SEARCH.STATUS.TRIP.CURRENT},
{translation: 'search.filters.past', value: CONST.SEARCH.STATUS.TRIP.PAST},
];

const taskStatusOptions: Array<MultiSelectItem<SingularSearchStatus>> = [
{translation: 'common.outstanding', value: CONST.SEARCH.STATUS.TASK.OUTSTANDING},
{translation: 'search.filters.completed', value: CONST.SEARCH.STATUS.TASK.COMPLETED},
];

let currentAccountID: number | undefined;
Onyx.connect({
key: ONYXKEYS.SESSION,
Expand Down Expand Up @@ -1371,6 +1414,36 @@ function isSearchDataLoaded(currentSearchResults: SearchResults | undefined, las
return isDataLoaded;
}

function getStatusOptions(type: SearchDataTypes, groupBy: SearchGroupBy | undefined) {
switch (type) {
case CONST.SEARCH.DATA_TYPES.CHAT:
return chatStatusOptions;
case CONST.SEARCH.DATA_TYPES.INVOICE:
return invoiceStatusOptions;
case CONST.SEARCH.DATA_TYPES.TRIP:
return tripStatusOptions;
case CONST.SEARCH.DATA_TYPES.TASK:
return taskStatusOptions;
case CONST.SEARCH.DATA_TYPES.EXPENSE:
default:
return groupBy === CONST.SEARCH.GROUP_BY.REPORTS ? expenseReportStatusOptions : expenseStatusOptions;
}
}

function getTypeOptions(policies: OnyxCollection<OnyxTypes.Policy>, currentUserLogin?: string) {
const typeOptions: Array<SingleSelectItem<SearchDataTypes>> = [
{translation: 'common.expense', value: CONST.SEARCH.DATA_TYPES.EXPENSE},
{translation: 'common.chat', value: CONST.SEARCH.DATA_TYPES.CHAT},
{translation: 'common.invoice', value: CONST.SEARCH.DATA_TYPES.INVOICE},
{translation: 'common.trip', value: CONST.SEARCH.DATA_TYPES.TRIP},
{translation: 'common.task', value: CONST.SEARCH.DATA_TYPES.TASK},
];
const shouldHideInvoiceOption = !canSendInvoice(policies, currentUserLogin) && !hasInvoiceReports();

// Remove the invoice option if the user is not allowed to send invoices
return shouldHideInvoiceOption ? typeOptions.filter((typeOption) => typeOption.value !== CONST.SEARCH.DATA_TYPES.INVOICE) : typeOptions;
}

export {
getListItem,
getSections,
Expand All @@ -1392,6 +1465,8 @@ export {
shouldShowEmptyState,
compareValues,
isSearchDataLoaded,
getStatusOptions,
getTypeOptions,
getWideAmountIndicators,
isTransactionAmountTooLong,
isTransactionTaxAmountTooLong,
Expand Down
Loading