Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Hide invoice menu if the user can't send an invoice or has an invoice report #54945

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Changes from 2 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
6 changes: 3 additions & 3 deletions src/pages/Search/SearchTypeMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import useSingleExecution from '@hooks/useSingleExecution';
import useThemeStyles from '@hooks/useThemeStyles';
import * as SearchActions from '@libs/actions/Search';
import Navigation from '@libs/Navigation/Navigation';
import {getAllTaxRates, hasWorkspaceWithInvoices} from '@libs/PolicyUtils';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasWorkspaceWithInvoices is now unused. Let's remove that function definition

Copy link
Contributor Author

@etCoderDysto etCoderDysto Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the function definition 🙏.

import {canSendInvoice, getAllTaxRates} from '@libs/PolicyUtils';
import {hasInvoiceReports} from '@libs/ReportUtils';
import * as SearchQueryUtils from '@libs/SearchQueryUtils';
import * as SearchUIUtils from '@libs/SearchUIUtils';
Expand Down Expand Up @@ -71,7 +71,7 @@ function SearchTypeMenu({queryJSON, searchName}: SearchTypeMenuProps) {
);
const {showDeleteModal, DeleteConfirmModal} = useDeleteSavedSearch();
const [session] = useOnyx(ONYXKEYS.SESSION);

const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const personalDetails = usePersonalDetails();
const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
const taxRates = getAllTaxRates();
Expand All @@ -97,7 +97,7 @@ function SearchTypeMenu({queryJSON, searchName}: SearchTypeMenuProps) {
},
];

if (hasWorkspaceWithInvoices(session?.email) || hasInvoiceReports()) {
if (canSendInvoice(allPolicies, session?.email) || hasInvoiceReports()) {
typeMenuItems.push({
title: translate('workspace.common.invoices'),
type: CONST.SEARCH.DATA_TYPES.INVOICE,
Expand Down
Loading