Skip to content
Merged
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
16 changes: 2 additions & 14 deletions src/hooks/useSearchBulkActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import {
canReassignAsApprover,
getAllPolicyExpenseChatReportActions,
getIntegrationIcon,
INTEGRATION_ICON_NAMES,
getReportOrDraftReport,
hasOnlyHeldExpenses,
hasViolations as hasViolationsReportUtils,
Expand Down Expand Up @@ -799,20 +800,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
'ExpenseCopy',
'ReportCopy',
'RotateLeft',
'QBOSquare',
'IntuitSquare',
'XeroSquare',
'NetSuiteSquare',
'IntacctSquare',
'QBDSquare',
'CertiniaSquare',
'RilletSquare',
'DualEntrySquare',
'CampfireSquare',
'ZohoBooksSquare',
'BusinessCentralSquare',
'OdooSquare',
'GustoSquare',
...INTEGRATION_ICON_NAMES,
'Pencil',
'Workflows',
'Document',
Expand Down
43 changes: 21 additions & 22 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15051,30 +15051,28 @@ function getSourceIDFromReportAction(reportAction: OnyxEntry<ReportAction>): str
return sourceID;
}

/** Every icon getIntegrationIcon can return, so a caller that shows any integration loads them all */
const INTEGRATION_ICON_NAMES = [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NAB: Only this hook uses the new list. The other seven getIntegrationIcon callers still have their own copy. Adding 'DigitsSquare' to the hook's list like we did for Campfire would've been enough here. Fine to keep it though, and we can move the other callers to it in a follow-up.

'XeroSquare',
'QBOSquare',
'NetSuiteSquare',
'IntacctSquare',
'QBDSquare',
'CertiniaSquare',
'RilletSquare',
'DualEntrySquare',
'CampfireSquare',
'DigitsSquare',
'ZohoBooksSquare',
'BusinessCentralSquare',
'OdooSquare',
'GustoSquare',
'IntuitSquare',
] as const;

function getIntegrationIcon(
connectionName?: ConnectionName,
expensifyIcons?:
| Partial<
Record<
| 'XeroSquare'
| 'QBOSquare'
| 'NetSuiteSquare'
| 'IntacctSquare'
| 'QBDSquare'
| 'CertiniaSquare'
| 'RilletSquare'
| 'DualEntrySquare'
| 'CampfireSquare'
| 'DigitsSquare'
| 'ZohoBooksSquare'
| 'BusinessCentralSquare'
| 'OdooSquare'
| 'GustoSquare'
| 'IntuitSquare',
IconAsset
>
>
| undefined,
expensifyIcons?: Partial<Record<TupleToUnion<typeof INTEGRATION_ICON_NAMES>, IconAsset>> | undefined,
policy?: OnyxEntry<Policy>,
) {
if (connectionName === CONST.POLICY.CONNECTIONS.NAME.XERO) {
Expand Down Expand Up @@ -16716,6 +16714,7 @@ export {
getFieldViolation,
findPolicyExpenseChatByPolicyID,
getIntegrationIcon,
INTEGRATION_ICON_NAMES,
canBeExported,
canShareReport,
isExported,
Expand Down
34 changes: 34 additions & 0 deletions tests/unit/hooks/useSearchBulkActionsExportTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ const POLICY_ID_2 = 'policy2';
const NETSUITE_FRIENDLY_NAME = CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[CONST.POLICY.CONNECTIONS.NAME.NETSUITE];
const QBO_FRIENDLY_NAME = CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[CONST.POLICY.CONNECTIONS.NAME.QBO];
const IES_FRIENDLY_NAME = CONST.EXPORT_LABELS.INTUIT_ENTERPRISE_SUITE;
const DIGITS_FRIENDLY_NAME = CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[CONST.POLICY.CONNECTIONS.NAME.DIGITS];

const expenseReportQueryJSON: SearchQueryJSON = {
inputQuery: 'type:expense-report status:all',
Expand Down Expand Up @@ -780,6 +781,39 @@ describe('useSearchBulkActions - export options', () => {
});
});

it('offers the Digits export option with the Digits icon and marks reports as exported to Digits', async () => {
// Given a selected report on a workspace connected to Digits
await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${POLICY_ID_2}`, {
id: POLICY_ID_2,
connections: {[CONST.POLICY.CONNECTIONS.NAME.DIGITS]: {}},
});
mockCurrentSearchResults = makeSearchResults([makeSnapshotReport(REPORT_ID_2, POLICY_ID_2)]);
mockSelectedReports = [makeSelectedReport({reportID: REPORT_ID_2, policyID: POLICY_ID_2})];
mockSelectedTransactions = {tx2: makeSelectedTransaction({reportID: REPORT_ID_2, policyID: POLICY_ID_2})};

// When the export bulk-action menu is built
const {result} = renderHook(() => useSearchBulkActions({queryJSON: expenseReportQueryJSON}), {wrapper: OnyxListItemProvider});
await waitFor(() => {
const subMenuItems = getExportSubMenuItems(result.current.headerButtonsOptions);
expect(subMenuItems?.some((item) => item.text === DIGITS_FRIENDLY_NAME)).toBe(true);
});

// Then the Digits option shows the Digits icon like the other integrations, which needs the icon loaded by the hook
const subMenuItems = getExportSubMenuItems(result.current.headerButtonsOptions) ?? [];
expect(subMenuItems.find((item) => item.text === DIGITS_FRIENDLY_NAME)?.icon).toBe('DigitsSquare');

// When the admin picks the Digits "Mark as exported" option
const markAsExportedDigitsOption = subMenuItems.find(
(item) => item.text === 'workspace.common.markAsExported' && item.accessibilityLabel === `workspace.common.markAsExported, ${DIGITS_FRIENDLY_NAME}`,
);
markAsExportedDigitsOption?.onSelected?.();

// Then the report is marked as exported to Digits
await waitFor(() => {
expect(markAsManuallyExported).toHaveBeenCalledWith([REPORT_ID_2], CONST.POLICY.CONNECTIONS.NAME.DIGITS, expect.objectContaining({id: POLICY_ID_2}));
});
});

it('blocks the export and shows the different-companies modal when the selection spans one integration on different companyIDs', async () => {
/**
* Given: two approved reports on two workspaces both connected to NetSuite, but to DIFFERENT
Expand Down
Loading