From c4b5f94f89c2bf3834da3d92e3ea3779cd73be06 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 7 Oct 2026 17:31:37 -0600 Subject: [PATCH] Use Custom date for the Insights date filter --- .../Search/FilterComponents/DatePresetFilterBase.tsx | 3 +-- .../Search/FilterDropdowns/DateSelectPopup/index.tsx | 4 +--- .../DatePresetFilterBaseCustomDateModifiersTest.tsx | 12 ++++++------ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/components/Search/FilterComponents/DatePresetFilterBase.tsx b/src/components/Search/FilterComponents/DatePresetFilterBase.tsx index 7ba66d33a828..9b27cb57cefe 100644 --- a/src/components/Search/FilterComponents/DatePresetFilterBase.tsx +++ b/src/components/Search/FilterComponents/DatePresetFilterBase.tsx @@ -129,8 +129,7 @@ function DatePresetFilterBase({ const {translate, dateFnsLocale} = useLocalize(); const shouldShowHorizontalRule = !!presets?.length; - const isCustomDayOnly = allowedCustomDateModifiers.length === 1 && allowedCustomDateModifiers.at(0) === CONST.SEARCH.DATE_MODIFIERS.ON; - const customDateTitle = translate(isCustomDayOnly ? 'search.filters.date.customDay' : 'search.filters.date.customDate'); + const customDateTitle = translate('search.filters.date.customDate'); const customRangeTitle = translate('search.filters.date.customRange'); const normalizedDefaultDateValues = useMemo(() => normalizeDateValues(defaultDateValues), [defaultDateValues]); diff --git a/src/components/Search/FilterDropdowns/DateSelectPopup/index.tsx b/src/components/Search/FilterDropdowns/DateSelectPopup/index.tsx index 8f287b356b6b..7b6ade5671d3 100644 --- a/src/components/Search/FilterDropdowns/DateSelectPopup/index.tsx +++ b/src/components/Search/FilterDropdowns/DateSelectPopup/index.tsx @@ -65,9 +65,7 @@ function DateSelectPopup({label, value, presets, allowedCustomDateModifiers = CO [value, dateFnsLocale], ); const displayedRangeText = selectedDateModifier ? rangeText : syncedRangeText; - const isCustomDayOnly = allowedCustomDateModifiers.length === 1 && allowedCustomDateModifiers.at(0) === CONST.SEARCH.DATE_MODIFIERS.ON; - const selectedDateModifierTitle = - isCustomDayOnly && selectedDateModifier === CONST.SEARCH.DATE_MODIFIERS.ON ? translate('search.filters.date.customDay') : getDateModifierTitle(selectedDateModifier, '', translate); + const selectedDateModifierTitle = getDateModifierTitle(selectedDateModifier, '', translate); const updateRangeText = useCallback(() => { setRangeText(searchDatePresetFilterBaseRef.current?.getRangeDisplayText() ?? ''); diff --git a/tests/ui/DatePresetFilterBaseCustomDateModifiersTest.tsx b/tests/ui/DatePresetFilterBaseCustomDateModifiersTest.tsx index d36c66c6cc2d..0d7eaed60ba7 100644 --- a/tests/ui/DatePresetFilterBaseCustomDateModifiersTest.tsx +++ b/tests/ui/DatePresetFilterBaseCustomDateModifiersTest.tsx @@ -97,14 +97,14 @@ describe('DatePresetFilterBase allowedCustomDateModifiers', () => { } }); - it('offers a single-day calendar labelled Custom day when only On is allowed', () => { + it('offers a single-day calendar labelled Custom date when only On is allowed', () => { // Given the picker as Insights renders it, which only reports on closed periods const onSelectDateModifier = jest.fn(); renderDatePresetFilterBase({allowedCustomDateModifiers: [CONST.SEARCH.DATE_MODIFIERS.ON], onSelectDateModifier}); - expect(screen.queryByText(CUSTOM_DATE)).not.toBeOnTheScreen(); + expect(screen.queryByText(CUSTOM_DAY)).not.toBeOnTheScreen(); - // When the Custom day option is opened - fireEvent.press(screen.getByText(CUSTOM_DAY), PRESS_EVENT); + // When the Custom date option is opened + fireEvent.press(screen.getByText(CUSTOM_DATE), PRESS_EVENT); // Then the calendar opens on its own, since there is no modifier left to choose between expect(onSelectDateModifier).toHaveBeenCalledWith(CONST.SEARCH.DATE_MODIFIERS.ON); @@ -122,8 +122,8 @@ describe('DatePresetFilterBase allowedCustomDateModifiers', () => { onSelectDateModifier, }); - // When the Custom day option is opened - fireEvent.press(screen.getByText(CUSTOM_DAY), PRESS_EVENT); + // When the Custom date option is opened + fireEvent.press(screen.getByText(CUSTOM_DATE), PRESS_EVENT); // Then the picker switches to On rather than reviving the Before modifier the caller ruled out expect(onSelectDateModifier).toHaveBeenCalledWith(CONST.SEARCH.DATE_MODIFIERS.ON);