Skip to content
Merged
2 changes: 2 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6399,6 +6399,7 @@ const CONST = {
PAID: 'paid',
EXPORTED: 'exported',
POSTED: 'posted',
WITHDRAWN: 'withdrawn',
TITLE: 'title',
ASSIGNEE: 'assignee',
REIMBURSABLE: 'reimbursable',
Expand Down Expand Up @@ -6443,6 +6444,7 @@ const CONST = {
PAID: 'paid',
EXPORTED: 'exported',
POSTED: 'posted',
WITHDRAWN: 'withdrawn',
TITLE: 'title',
ASSIGNEE: 'assignee',
REIMBURSABLE: 'reimbursable',
Expand Down
1 change: 1 addition & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const ROUTES = {
SEARCH_ADVANCED_FILTERS_PAID: 'search/filters/paid',
SEARCH_ADVANCED_FILTERS_EXPORTED: 'search/filters/exported',
SEARCH_ADVANCED_FILTERS_POSTED: 'search/filters/posted',
SEARCH_ADVANCED_FILTERS_WITHDRAWN: 'search/filters/withdrawn',
SEARCH_ADVANCED_FILTERS_TITLE: 'search/filters/title',
SEARCH_ADVANCED_FILTERS_ASSIGNEE: 'search/filters/assignee',
SEARCH_ADVANCED_FILTERS_REIMBURSABLE: 'search/filters/reimbursable',
Expand Down
1 change: 1 addition & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const SCREENS = {
ADVANCED_FILTERS_PAID_RHP: 'Search_Advanced_Filters_Paid_RHP',
ADVANCED_FILTERS_EXPORTED_RHP: 'Search_Advanced_Filters_Exported_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',
ADVANCED_FILTERS_DESCRIPTION_RHP: 'Search_Advanced_Filters_Description_RHP',
ADVANCED_FILTERS_MERCHANT_RHP: 'Search_Advanced_Filters_Merchant_RHP',
Expand Down
1 change: 1 addition & 0 deletions src/components/Search/SearchAutocompleteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ function SearchAutocompleteList(
text: status,
}));
}
case CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN:
case CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED:
case CONST.SEARCH.SYNTAX_FILTER_KEYS.POSTED: {
const filteredDatePresets = (getDatePresets(autocompleteKey, true) ?? [])
Expand Down
127 changes: 89 additions & 38 deletions src/components/Search/SearchPageHeader/SearchFiltersBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import SingleSelectPopup from '@components/Search/FilterDropdowns/SingleSelectPo
import UserSelectPopup from '@components/Search/FilterDropdowns/UserSelectPopup';
import {useSearchContext} from '@components/Search/SearchContext';
import type {SearchDateValues} from '@components/Search/SearchDatePresetFilterBase';
import type {SearchQueryJSON, SingularSearchStatus} from '@components/Search/types';
import type {SearchDateFilterKeys, SearchQueryJSON, SingularSearchStatus} from '@components/Search/types';
import SearchFiltersSkeleton from '@components/Skeletons/SearchFiltersSkeleton';
import useEnvironment from '@hooks/useEnvironment';
import useLocalize from '@hooks/useLocalize';
Expand All @@ -42,6 +42,7 @@ import {
} from '@libs/SearchQueryUtils';
import {getDatePresets, getFeedOptions, getGroupByOptions, getStatusOptions, getTypeOptions} from '@libs/SearchUIUtils';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {SearchAdvancedFiltersForm} from '@src/types/form';
Expand Down Expand Up @@ -142,26 +143,51 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions, isMobileSelectionMod
return [value, displayText];
}, [filterFormValues.dateOn, filterFormValues.dateAfter, filterFormValues.dateBefore, translate]);

const [posted, displayPosted] = useMemo(() => {
const value: SearchDateValues = {
[CONST.SEARCH.DATE_MODIFIERS.ON]: filterFormValues.postedOn,
[CONST.SEARCH.DATE_MODIFIERS.AFTER]: filterFormValues.postedAfter,
[CONST.SEARCH.DATE_MODIFIERS.BEFORE]: filterFormValues.postedBefore,
};
const createDateDisplayValue = useCallback(
(filterValues: {on?: string; after?: string; before?: string}): [SearchDateValues, string[]] => {
const value: SearchDateValues = {
[CONST.SEARCH.DATE_MODIFIERS.ON]: filterValues.on,
[CONST.SEARCH.DATE_MODIFIERS.AFTER]: filterValues.after,
[CONST.SEARCH.DATE_MODIFIERS.BEFORE]: filterValues.before,
};

const displayText: string[] = [];
if (value.On) {
displayText.push(isSearchDatePreset(value.On) ? translate(`search.filters.date.presets.${value.On}`) : `${translate('common.on')} ${DateUtils.formatToReadableString(value.On)}`);
}
if (value.After) {
displayText.push(`${translate('common.after')} ${DateUtils.formatToReadableString(value.After)}`);
}
if (value.Before) {
displayText.push(`${translate('common.before')} ${DateUtils.formatToReadableString(value.Before)}`);
}
const displayText: string[] = [];
if (value.On) {
displayText.push(
isSearchDatePreset(value.On) ? translate(`search.filters.date.presets.${value.On}`) : `${translate('common.on')} ${DateUtils.formatToReadableString(value.On)}`,
);
}
if (value.After) {
displayText.push(`${translate('common.after')} ${DateUtils.formatToReadableString(value.After)}`);
}
if (value.Before) {
displayText.push(`${translate('common.before')} ${DateUtils.formatToReadableString(value.Before)}`);
}

return [value, displayText];
}, [filterFormValues.postedOn, filterFormValues.postedAfter, filterFormValues.postedBefore, translate]);
return [value, displayText];
},
[translate],
);

const [posted, displayPosted] = useMemo(
() =>
createDateDisplayValue({
on: filterFormValues.postedOn,
after: filterFormValues.postedAfter,
before: filterFormValues.postedBefore,
}),
[filterFormValues.postedOn, filterFormValues.postedAfter, filterFormValues.postedBefore, createDateDisplayValue],
);

const [withdrawn, displayWithdrawn] = useMemo(
() =>
createDateDisplayValue({
on: filterFormValues.withdrawnOn,
after: filterFormValues.withdrawnAfter,
before: filterFormValues.withdrawnBefore,
}),
[filterFormValues.withdrawnOn, filterFormValues.withdrawnAfter, filterFormValues.withdrawnBefore, createDateDisplayValue],
);

const updateFilterForm = useCallback(
(values: Partial<SearchAdvancedFiltersForm>) => {
Expand Down Expand Up @@ -236,29 +262,38 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions, isMobileSelectionMod
[translate, feedOptions, feed, updateFilterForm],
);

const postedPickerComponent = useCallback(
({closeOverlay}: PopoverComponentProps) => {
const onChange = (selectedDates: SearchDateValues) => {
const dateFormValues = {
postedOn: selectedDates[CONST.SEARCH.DATE_MODIFIERS.ON],
postedAfter: selectedDates[CONST.SEARCH.DATE_MODIFIERS.AFTER],
postedBefore: selectedDates[CONST.SEARCH.DATE_MODIFIERS.BEFORE],
const createDatePickerComponent = useCallback(
(filterKey: SearchDateFilterKeys, value: SearchDateValues, translationKey: TranslationPaths) => {
return ({closeOverlay}: PopoverComponentProps) => {
const onChange = (selectedDates: SearchDateValues) => {
const dateFormValues = {
[`${filterKey}On`]: selectedDates[CONST.SEARCH.DATE_MODIFIERS.ON],
[`${filterKey}After`]: selectedDates[CONST.SEARCH.DATE_MODIFIERS.AFTER],
[`${filterKey}Before`]: selectedDates[CONST.SEARCH.DATE_MODIFIERS.BEFORE],
};

updateFilterForm(dateFormValues);
};

updateFilterForm(dateFormValues);
return (
<DateSelectPopup
label={translate(translationKey)}
value={value}
onChange={onChange}
closeOverlay={closeOverlay}
presets={getDatePresets(filterKey, true)}
/>
);
};

return (
<DateSelectPopup
label={translate('search.filters.posted')}
value={posted}
onChange={onChange}
closeOverlay={closeOverlay}
presets={getDatePresets(CONST.SEARCH.SYNTAX_FILTER_KEYS.POSTED, true)}
/>
);
},
[posted, translate, updateFilterForm],
[translate, updateFilterForm],
);

const postedPickerComponent = useMemo(() => createDatePickerComponent(CONST.SEARCH.SYNTAX_FILTER_KEYS.POSTED, posted, 'search.filters.posted'), [createDatePickerComponent, posted]);

const withdrawnPickerComponent = useMemo(
() => createDatePickerComponent(CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN, withdrawn, 'search.filters.withdrawn'),
[createDatePickerComponent, withdrawn],
);

const statusComponent = useCallback(
Expand Down Expand Up @@ -331,6 +366,7 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions, isMobileSelectionMod
const shouldDisplayGroupByFilter = isDevelopment;
const shouldDisplayFeedFilter = feedOptions.length > 1 && !!filterFormValues.feed;
const shouldDisplayPostedFilter = !!filterFormValues.feed && (!!filterFormValues.postedOn || !!filterFormValues.postedAfter || !!filterFormValues.postedBefore);
const shouldDisplayWithdrawnFilter = !!filterFormValues.withdrawnOn || !!filterFormValues.withdrawnAfter || !!filterFormValues.withdrawnBefore;

const filterList = [
{
Expand Down Expand Up @@ -369,6 +405,16 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions, isMobileSelectionMod
},
]
: []),
...(shouldDisplayWithdrawnFilter
? [
{
label: translate('search.filters.withdrawn'),
PopoverComponent: withdrawnPickerComponent,
value: displayWithdrawn,
filterKey: FILTER_KEYS.WITHDRAWN_ON,
},
]
: []),
{
label: translate('common.status'),
PopoverComponent: statusComponent,
Expand All @@ -395,18 +441,23 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions, isMobileSelectionMod
groupBy,
displayDate,
displayPosted,
displayWithdrawn,
filterFormValues.from,
filterFormValues.feed,
filterFormValues.postedOn,
filterFormValues.postedAfter,
filterFormValues.postedBefore,
filterFormValues.withdrawnOn,
filterFormValues.withdrawnAfter,
filterFormValues.withdrawnBefore,
translate,
typeComponent,
groupByComponent,
statusComponent,
datePickerComponent,
userPickerComponent,
postedPickerComponent,
withdrawnPickerComponent,
status,
personalDetails,
isDevelopment,
Expand Down
3 changes: 2 additions & 1 deletion src/components/Search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ type SearchDateFilterKeys =
| typeof CONST.SEARCH.SYNTAX_FILTER_KEYS.APPROVED
| typeof CONST.SEARCH.SYNTAX_FILTER_KEYS.PAID
| typeof CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED
| typeof CONST.SEARCH.SYNTAX_FILTER_KEYS.POSTED;
| typeof CONST.SEARCH.SYNTAX_FILTER_KEYS.POSTED
| typeof CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN;

type SearchFilterKey =
| ValueOf<typeof CONST.SEARCH.SYNTAX_FILTER_KEYS>
Expand Down
1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6003,6 +6003,7 @@ const translations = {
paid: 'Zahlungsdatum',
exported: 'Exportiertes Datum',
posted: 'Buchungsdatum',
withdrawn: 'Storniert',
billable: 'Abrechenbar',
reimbursable: 'Erstattungsfähig',
groupBy: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5975,6 +5975,7 @@ const translations = {
paid: 'Paid date',
exported: 'Exported date',
posted: 'Posted date',
withdrawn: 'Withdrawn date',
billable: 'Billable',
reimbursable: 'Reimbursable',
groupBy: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5997,6 +5997,7 @@ const translations = {
paid: 'Fecha de pago',
exported: 'Fecha de exportación',
posted: 'Fecha de contabilización',
withdrawn: 'Fecha de retirada',
billable: 'Facturable',
reimbursable: 'Reembolsable',
groupBy: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6016,6 +6016,7 @@ const translations = {
paid: 'Date de paiement',
exported: 'Date exportée',
posted: 'Date de publication',
withdrawn: 'Date de retrait',
billable: 'Facturable',
reimbursable: 'Remboursable',
groupBy: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6018,6 +6018,7 @@ const translations = {
paid: 'Data di pagamento',
exported: 'Data esportata',
posted: 'Data di pubblicazione',
withdrawn: 'Data di ritiro',
billable: 'Fatturabile',
reimbursable: 'Rimborsabile',
groupBy: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5976,6 +5976,7 @@ const translations = {
paid: '支払日',
exported: 'エクスポートされた日付',
posted: '投稿日',
withdrawn: '取り消し日',
billable: 'ビラブル',
reimbursable: '払い戻し可能',
groupBy: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6010,6 +6010,7 @@ const translations = {
paid: 'Betaaldatum',
exported: 'Geëxporteerde datum',
posted: 'Geplaatste datum',
withdrawn: 'Teruggetrokken datum',
billable: 'Factureerbaar',
reimbursable: 'Vergoedbaar',
groupBy: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5995,6 +5995,7 @@ const translations = {
paid: 'Data płatności',
exported: 'Data eksportu',
posted: 'Data opublikowania',
withdrawn: 'Data wycofania',
billable: 'Podlegające fakturowaniu',
reimbursable: 'Podlegające zwrotowi',
groupBy: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6009,6 +6009,7 @@ const translations = {
paid: 'Data de pagamento',
exported: 'Data exportada',
posted: 'Data de postagem',
withdrawn: 'Data de retirada',
billable: 'Faturável',
reimbursable: 'Reembolsável',
groupBy: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5900,6 +5900,7 @@ const translations = {
paid: '支付日期',
exported: '导出日期',
posted: '发布日期',
withdrawn: '撤回日期',
billable: '可计费的',
reimbursable: '可报销的',
groupBy: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ const SearchAdvancedFiltersModalStackNavigator = createModalStackNavigator<Searc
[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_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,
[SCREENS.SEARCH.ADVANCED_FILTERS_DESCRIPTION_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage/SearchFiltersDescriptionPage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_MERCHANT_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage/SearchFiltersMerchantPage').default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const SEARCH_TO_RHP: Partial<Record<keyof SearchFullscreenNavigatorParamList, st
SCREENS.SEARCH.ADVANCED_FILTERS_PAID_RHP,
SCREENS.SEARCH.ADVANCED_FILTERS_EXPORTED_RHP,
SCREENS.SEARCH.ADVANCED_FILTERS_POSTED_RHP,
SCREENS.SEARCH.ADVANCED_FILTERS_WITHDRAWN_RHP,
SCREENS.SEARCH.ADVANCED_FILTERS_DESCRIPTION_RHP,
SCREENS.SEARCH.ADVANCED_FILTERS_MERCHANT_RHP,
SCREENS.SEARCH.ADVANCED_FILTERS_REPORT_ID_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 @@ -1448,6 +1448,7 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
[SCREENS.SEARCH.ADVANCED_FILTERS_PAID_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_PAID,
[SCREENS.SEARCH.ADVANCED_FILTERS_EXPORTED_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_EXPORTED,
[SCREENS.SEARCH.ADVANCED_FILTERS_POSTED_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_POSTED,
[SCREENS.SEARCH.ADVANCED_FILTERS_WITHDRAWN_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_WITHDRAWN,
[SCREENS.SEARCH.ADVANCED_FILTERS_CURRENCY_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_CURRENCY,
[SCREENS.SEARCH.ADVANCED_FILTERS_MERCHANT_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_MERCHANT,
[SCREENS.SEARCH.ADVANCED_FILTERS_DESCRIPTION_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_DESCRIPTION,
Expand Down
1 change: 1 addition & 0 deletions src/libs/SearchAutocompleteUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ function filterOutRangesWithCorrectValue(
case CONST.SEARCH.SYNTAX_FILTER_KEYS.REIMBURSABLE:
return booleanList.includes(range.value);
case CONST.SEARCH.SYNTAX_FILTER_KEYS.POSTED:
case CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN:
case CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED:
return datePresetList.includes(range.value);
default:
Expand Down
Loading
Loading