Skip to content
Draft
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
5 changes: 5 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@ const CONST = {
XERO: 'xero',
NETSUITE: 'netsuite',
SAGE_INTACCT: 'intacct',
CERTINIA: 'certinia',
},
SUPPORTED_ONLY_ON_OLDDOT: {
FINANCIALFORCE: 'financialForce',
Expand All @@ -3295,6 +3296,7 @@ const CONST = {
xero: 'Xero',
intacct: 'Sage Intacct',
financialForce: 'FinancialForce',
certinia: 'Certinia',
billCom: 'Bill.com',
zenefits: 'Zenefits',
sap: 'SAP',
Expand Down Expand Up @@ -7225,6 +7227,7 @@ const CONST = {
ATTENDEE: 'attendee',
IS: 'is',
REPORT_FIELD: 'reportField',
EXPORTED_TO: 'exportedTo',
},
REPORT_FIELD: {
// All report fields start with this, so use this to check if a search key is a report field
Expand Down Expand Up @@ -7291,6 +7294,7 @@ const CONST = {
ATTENDEE: 'attendee',
IS: 'is',
REPORT_FIELD: 'report-field',
EXPORTED_TO: 'exported-to',
COLUMNS: 'columns',
LIMIT: 'limit',
},
Expand Down Expand Up @@ -7404,6 +7408,7 @@ const CONST = {
},
TODO_BADGE_MAX_COUNT: 50,
TOP_SEARCH_LIMIT: 10,
PREDEFINED_INTEGRATION_FILTER_VALUES: ['xero', 'qbo', 'qbd', 'netsuite', 'intacct', 'certinia'],
},
SEARCH_SELECTOR: {
SELECTION_MODE_SINGLE: 'single',
Expand Down
1 change: 1 addition & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const SCREENS = {
ADVANCED_FILTERS_APPROVED_RHP: 'Search_Advanced_Filters_Approved_RHP',
ADVANCED_FILTERS_PAID_RHP: 'Search_Advanced_Filters_Paid_RHP',
ADVANCED_FILTERS_EXPORTED_RHP: 'Search_Advanced_Filters_Exported_RHP',
ADVANCED_FILTERS_EXPORTED_TO_RHP: 'Search_Advanced_Filters_Exported_To_RHP',
ADVANCED_FILTERS_POSTED_RHP: 'Search_Advanced_Filters_Posted_RHP',
ADVANCED_FILTERS_WITHDRAWN_RHP: 'Search_Advanced_Filters_Withdrawn_RHP',
ADVANCED_FILTERS_CURRENCY_RHP: 'Search_Advanced_Filters_Currency_RHP',
Expand Down
22 changes: 22 additions & 0 deletions src/components/Search/SearchAutocompleteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import {getExportTemplates} from '@libs/actions/Search';
import {getCardFeedsForDisplay} from '@libs/CardFeedUtils';
import {getCardDescription, isCard, isCardHiddenFromSearch} from '@libs/CardUtils';
import {getDecodedCategoryName} from '@libs/CategoryUtils';
Expand Down Expand Up @@ -340,6 +341,15 @@ function SearchAutocompleteList({
}, [allPoliciesTags]);
const recentTagsAutocompleteList = useMemo(() => getAutocompleteRecentTags(allRecentTags), [allRecentTags]);

const [integrationsExportTemplates] = useOnyx(ONYXKEYS.NVP_INTEGRATION_SERVER_EXPORT_TEMPLATES, {canBeMissing: true});
const [csvExportLayouts] = useOnyx(ONYXKEYS.NVP_CSV_EXPORT_LAYOUTS, {canBeMissing: true});
const exportedToAutocompleteList = useMemo(() => {
const predefinedValues = CONST.SEARCH.PREDEFINED_INTEGRATION_FILTER_VALUES;
const exportTemplates = getExportTemplates(integrationsExportTemplates ?? [], csvExportLayouts ?? {}, translate, undefined, true);
const customNames = exportTemplates.map((t) => t.templateName).filter(Boolean);
return [...new Set([...predefinedValues, ...customNames])];
}, [integrationsExportTemplates, csvExportLayouts, translate]);

const [autocompleteParsedQuery, autocompleteQueryWithoutFilters] = useMemo(() => {
const queryWithoutFilters = getQueryWithoutFilters(autocompleteQueryValue);
return [parsedQuery, queryWithoutFilters];
Expand Down Expand Up @@ -633,6 +643,17 @@ function SearchAutocompleteList({
case CONST.SEARCH.SYNTAX_FILTER_KEYS.SUBMITTED:
case CONST.SEARCH.SYNTAX_FILTER_KEYS.APPROVED:
case CONST.SEARCH.SYNTAX_FILTER_KEYS.PAID:
case CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO: {
const filteredExportedTo = exportedToAutocompleteList
.filter((value) => value.toLowerCase().includes(autocompleteValue.toLowerCase()) && !alreadyAutocompletedKeys.has(value.toLowerCase()))
.sort()
.slice(0, 10);
return filteredExportedTo.map((value) => ({
filterKey: CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.EXPORTED_TO,
text: value,
mapKey: CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO,
}));
}
case CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED:
case CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN:
case CONST.SEARCH.SYNTAX_FILTER_KEYS.POSTED: {
Expand Down Expand Up @@ -674,6 +695,7 @@ function SearchAutocompleteList({
hasAutocompleteList,
isAutocompleteList,
visibleReportActionsData,
exportedToAutocompleteList,
]);

const sortedRecentSearches = useMemo(() => {
Expand Down
21 changes: 14 additions & 7 deletions src/components/Search/SearchMultipleSelectionPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import SearchFilterPageFooterButtons from './SearchFilterPageFooterButtons';
type SearchMultipleSelectionPickerItem = {
name: string;
value: string | string[];
leftElement?: React.ReactNode;
};

type SearchMultipleSelectionPickerProps = {
Expand All @@ -37,12 +38,16 @@ function SearchMultipleSelectionPicker({items, initiallySelectedItems, pickerTit
const selectedItemsSection = selectedItems
.filter((item) => item?.name.toLowerCase().includes(debouncedSearchTerm?.toLowerCase()))
.sort((a, b) => sortOptionsWithEmptyValue(a.value.toString(), b.value.toString(), localeCompare))
.map((item) => ({
text: item.name,
keyForList: item.name,
isSelected: true,
value: item.value,
}));
.map((item) => {
const fullItem = items.find((i) => i.value.toString() === item.value.toString());
return {
text: item.name,
keyForList: item.name,
isSelected: true,
value: item.value,
leftElement: fullItem?.leftElement,
};
});
const remainingItemsSection = items
.filter(
(item) =>
Expand All @@ -54,6 +59,7 @@ function SearchMultipleSelectionPicker({items, initiallySelectedItems, pickerTit
keyForList: item.name,
isSelected: false,
value: item.value,
leftElement: item.leftElement,
}));
const isEmpty = !selectedItemsSection.length && !remainingItemsSection.length;
return {
Expand Down Expand Up @@ -83,7 +89,8 @@ function SearchMultipleSelectionPicker({items, initiallySelectedItems, pickerTit
if (item.isSelected) {
setSelectedItems(selectedItems?.filter((selectedItem) => selectedItem.name !== item.keyForList));
} else {
setSelectedItems([...(selectedItems ?? []), {name: item.text, value: item.value}]);
const fullItem = items.find((i) => i.value.toString() === (item.value ?? '').toString());
setSelectedItems([...(selectedItems ?? []), {name: item.text, value: item.value, leftElement: fullItem?.leftElement}]);
}
},
[selectedItems],
Expand Down
3 changes: 3 additions & 0 deletions src/hooks/useAdvancedSearchFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const typeFiltersKeys = {
CONST.SEARCH.SYNTAX_FILTER_KEYS.APPROVED,
CONST.SEARCH.SYNTAX_FILTER_KEYS.PAID,
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED,
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_TYPE,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_ID,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN,
Expand All @@ -79,6 +80,7 @@ const typeFiltersKeys = {
CONST.SEARCH.SYNTAX_FILTER_KEYS.APPROVED,
CONST.SEARCH.SYNTAX_FILTER_KEYS.PAID,
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED,
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_TYPE,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_ID,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN,
Expand Down Expand Up @@ -154,6 +156,7 @@ const typeFiltersKeys = {
CONST.SEARCH.SYNTAX_FILTER_KEYS.APPROVED,
CONST.SEARCH.SYNTAX_FILTER_KEYS.PAID,
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED,
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO,
CONST.SEARCH.SYNTAX_FILTER_KEYS.TITLE,
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,7 @@ const SearchAdvancedFiltersModalStackNavigator = createModalStackNavigator<Searc
[SCREENS.SEARCH.ADVANCED_FILTERS_APPROVED_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage/SearchFiltersApprovedPage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_PAID_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage/SearchFiltersPaidPage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_EXPORTED_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage/SearchFiltersExportedPage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_EXPORTED_TO_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage/SearchFiltersExportedToPage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_POSTED_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage/SearchFiltersPostedPage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_WITHDRAWN_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage/SearchFiltersWithdrawnPage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_CURRENCY_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage/SearchFiltersCurrencyPage').default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const SEARCH_TO_RHP: Partial<Record<keyof SearchFullscreenNavigatorParamList, st
SCREENS.SEARCH.ADVANCED_FILTERS_APPROVED_RHP,
SCREENS.SEARCH.ADVANCED_FILTERS_PAID_RHP,
SCREENS.SEARCH.ADVANCED_FILTERS_EXPORTED_RHP,
SCREENS.SEARCH.ADVANCED_FILTERS_EXPORTED_TO_RHP,
SCREENS.SEARCH.ADVANCED_FILTERS_POSTED_RHP,
SCREENS.SEARCH.ADVANCED_FILTERS_WITHDRAWN_RHP,
SCREENS.SEARCH.ADVANCED_FILTERS_DESCRIPTION_RHP,
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,7 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
[SCREENS.SEARCH.ADVANCED_FILTERS_APPROVED_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS.getRoute(CONST.SEARCH.SYNTAX_FILTER_KEYS.APPROVED),
[SCREENS.SEARCH.ADVANCED_FILTERS_PAID_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS.getRoute(CONST.SEARCH.SYNTAX_FILTER_KEYS.PAID),
[SCREENS.SEARCH.ADVANCED_FILTERS_EXPORTED_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS.getRoute(CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED),
[SCREENS.SEARCH.ADVANCED_FILTERS_EXPORTED_TO_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS.getRoute(CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO),
[SCREENS.SEARCH.ADVANCED_FILTERS_POSTED_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS.getRoute(CONST.SEARCH.SYNTAX_FILTER_KEYS.POSTED),
[SCREENS.SEARCH.ADVANCED_FILTERS_WITHDRAWN_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS.getRoute(CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN),
[SCREENS.SEARCH.ADVANCED_FILTERS_CURRENCY_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS.getRoute(CONST.SEARCH.SYNTAX_FILTER_KEYS.CURRENCY),
Expand Down
39 changes: 38 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12355,7 +12355,10 @@ function getSourceIDFromReportAction(reportAction: OnyxEntry<ReportAction>): str
return sourceID;
}

function getIntegrationIcon(connectionName?: ConnectionName, expensifyIcons?: Record<'XeroSquare' | 'QBOSquare' | 'NetSuiteSquare' | 'IntacctSquare' | 'QBDSquare', IconAsset> | undefined) {
function getIntegrationIcon(
connectionName?: ConnectionName,
expensifyIcons?: Record<'XeroSquare' | 'QBOSquare' | 'NetSuiteSquare' | 'IntacctSquare' | 'QBDSquare' | 'CertiniaSquare', IconAsset> | undefined,
) {
if (connectionName === CONST.POLICY.CONNECTIONS.NAME.XERO) {
return expensifyIcons?.XeroSquare;
}
Expand All @@ -12371,6 +12374,38 @@ function getIntegrationIcon(connectionName?: ConnectionName, expensifyIcons?: Re
if (connectionName === CONST.POLICY.CONNECTIONS.NAME.QBD) {
return expensifyIcons?.QBDSquare;
}
if (connectionName === CONST.POLICY.CONNECTIONS.NAME.CERTINIA) {
return expensifyIcons?.CertiniaSquare;
}

return undefined;
}

function getConnectionNameForExportedToFilter(value: string): ConnectionName | undefined {
const map: Record<string, AllConnectionName> = {
xero: CONST.POLICY.CONNECTIONS.NAME.XERO,
qbo: CONST.POLICY.CONNECTIONS.NAME.QBO,
qbd: CONST.POLICY.CONNECTIONS.NAME.QBD,
netsuite: CONST.POLICY.CONNECTIONS.NAME.NETSUITE,
intacct: CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT,
certinia: CONST.POLICY.CONNECTIONS.NAME.CERTINIA,
};
return map[value.toLowerCase()];
}

function getIntegrationExportIcon(connectionName?: ConnectionName): 'XeroExport' | 'QBOExport' | 'NetSuiteExport' | 'SageIntacctExport' | undefined {
if (connectionName === CONST.POLICY.CONNECTIONS.NAME.XERO) {
return 'XeroExport';
}
if (connectionName === CONST.POLICY.CONNECTIONS.NAME.QBO || connectionName === CONST.POLICY.CONNECTIONS.NAME.QBD) {
return 'QBOExport';
}
if (connectionName === CONST.POLICY.CONNECTIONS.NAME.NETSUITE) {
return 'NetSuiteExport';
}
if (connectionName === CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT) {
return 'SageIntacctExport';
}

return undefined;
}
Expand Down Expand Up @@ -13358,7 +13393,9 @@ export {
getFieldViolation,
getReportViolations,
findPolicyExpenseChatByPolicyID,
getConnectionNameForExportedToFilter,
getIntegrationIcon,
getIntegrationExportIcon,
canBeExported,
isExported,
hasExportError,
Expand Down
2 changes: 2 additions & 0 deletions src/libs/SearchAutocompleteUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ function filterOutRangesWithCorrectValue(
case CONST.SEARCH.SYNTAX_FILTER_KEYS.DESCRIPTION:
case CONST.SEARCH.SYNTAX_FILTER_KEYS.TITLE:
return range.value.length > 0;
case CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO:
return CONST.SEARCH.PREDEFINED_INTEGRATION_FILTER_VALUES.includes(range.value.toLowerCase());
case CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_ID:
case CONST.SEARCH.SYNTAX_FILTER_KEYS.REPORT_ID:
return !['', 'null', 'undefined', '0', '-1'].includes(range.value);
Expand Down
Loading
Loading