Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
da892dc
feat: Don't inject search syntax into the NewDot search field unless …
TaduJR Nov 23, 2025
1a87940
refactor: remove unrelated refactoring and fix useEffect dependencies
TaduJR Nov 24, 2025
ef60ce0
chore: remove unused isDefaultQuery variable and import
TaduJR Nov 24, 2025
9fe1b5d
Merge branch 'Expensify:main' into feat-Dont-inject-search-syntax-int…
TaduJR Nov 24, 2025
7455c90
Merge branch 'Expensify:main' into feat-Dont-inject-search-syntax-int…
TaduJR Nov 24, 2025
d54e7ea
chore: CI restart
TaduJR Nov 24, 2025
dd776bf
Merge branch 'Expensify:main' into feat-Dont-inject-search-syntax-int…
TaduJR Nov 25, 2025
1f85157
Merge branch 'Expensify:main' into feat-Dont-inject-search-syntax-int…
TaduJR Nov 27, 2025
e0081de
Merge branch 'main' of https://github.com/TaduJR/App into feat-Dont-i…
TaduJR Nov 29, 2025
0ffedf6
Merge branch 'main' of https://github.com/Expensify/App into feat-Don…
TaduJR Dec 2, 2025
5a06ee7
Merge branch 'Expensify:main' into feat-Dont-inject-search-syntax-int…
TaduJR Dec 2, 2025
8221a29
Merge branch 'main' of https://github.com/Expensify/App into feat-Don…
TaduJR Dec 3, 2025
df7950d
Merge branch 'Expensify:main' into feat-Dont-inject-search-syntax-int…
TaduJR Dec 3, 2025
c96ceb6
Merge branch 'Expensify:main' into feat-Dont-inject-search-syntax-int…
TaduJR Dec 4, 2025
5ae96e8
Merge branch 'main' of https://github.com/TaduJR/App into feat-Dont-i…
TaduJR Dec 5, 2025
7ccb044
fix: X button should only clear input text, not reset search or navigate
TaduJR Dec 5, 2025
5428c00
Merge branch 'Expensify:main' into feat-Dont-inject-search-syntax-int…
TaduJR Dec 6, 2025
c43f5ed
Merge branch 'main' of https://github.com/TaduJR/App into feat-Dont-i…
TaduJR Dec 10, 2025
0a8aa54
Merge branch 'Expensify:main' into feat-Dont-inject-search-syntax-int…
TaduJR Dec 10, 2025
ad334fa
Merge branch 'Expensify:main' into feat-Dont-inject-search-syntax-int…
TaduJR Dec 12, 2025
bb7a8b3
Merge branch 'main' of https://github.com/Expensify/App into feat-Don…
TaduJR Dec 17, 2025
d75b861
Merge branch 'feat-Dont-inject-search-syntax-into-the-NewDot-search-f…
TaduJR Dec 17, 2025
aebf97f
Merge branch 'main' of https://github.com/TaduJR/App into feat-Dont-i…
TaduJR Dec 19, 2025
cbdc3f7
fix: export clearAllFilters from Search actions
TaduJR Dec 19, 2025
1cbd0a4
chore: CI restart
TaduJR Dec 19, 2025
2a94cc9
fix: use clearAdvancedFilters instead of clearAllFilters
TaduJR Dec 19, 2025
cba01f9
Merge branch 'main' of https://github.com/TaduJR/App into feat-Dont-i…
TaduJR Dec 19, 2025
6b29d4e
Merge branch 'main' of https://github.com/TaduJR/App into feat-Dont-i…
TaduJR Dec 19, 2025
ce1e8f1
Merge branch 'main' of https://github.com/TaduJR/App into feat-Dont-i…
TaduJR Dec 22, 2025
28e9b25
fix: Remove redundant clearAdvancedFilters calls to prevent race cond…
TaduJR Dec 22, 2025
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
4 changes: 4 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,9 @@ const ONYXKEYS = {
/** Stores the information about the recent searches */
RECENT_SEARCHES: 'nvp_recentSearches',

/** Stores the current search page context (e.g., whether to show the search query) */
SEARCH_CONTEXT: 'searchContext',

/** Stores recently used currencies */
RECENTLY_USED_CURRENCIES: 'nvp_recentlyUsedCurrencies',

Expand Down Expand Up @@ -1157,6 +1160,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.NVP_TRY_NEW_DOT]: OnyxTypes.TryNewDot;
[ONYXKEYS.RECENT_SEARCHES]: Record<string, OnyxTypes.RecentSearchItem>;
[ONYXKEYS.SAVED_SEARCHES]: OnyxTypes.SaveSearch;
[ONYXKEYS.SEARCH_CONTEXT]: OnyxTypes.SearchContext;
[ONYXKEYS.RECENTLY_USED_CURRENCIES]: string[];
[ONYXKEYS.ACTIVE_CLIENTS]: string[];
[ONYXKEYS.DEVICE_ID]: string;
Expand Down
22 changes: 4 additions & 18 deletions src/components/Search/SearchAutocompleteInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import {setSearchContext} from '@libs/actions/Search';
import scheduleOnLiveMarkdownRuntime from '@libs/scheduleOnLiveMarkdownRuntime';
import {getAutocompleteCategories, getAutocompleteTags, parseForLiveMarkdown} from '@libs/SearchAutocompleteUtils';
import {buildCannedSearchQuery} from '@libs/SearchQueryUtils';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {SubstitutionMap} from './SearchRouter/getQueryWithSubstitutions';

type SearchAutocompleteInputProps = {
Expand Down Expand Up @@ -181,21 +179,9 @@ function SearchAutocompleteInput({
[currentUserPersonalDetails.displayName, substitutionMap, currencySharedValue, categorySharedValue, tagSharedValue, emailListSharedValue],
);

const clearFilters = useCallback(() => {
const clearInput = useCallback(() => {
onSearchQueryChange('');

// Check if we are on the search page before clearing query. If we are using the popup search menu,
// then the clear button is ONLY available when the search is *not* saved, so we don't have to navigate
const currentRoute = Navigation.getActiveRouteWithoutParams();
const isSearchPage = currentRoute === `/${ROUTES.SEARCH_ROOT.route}`;

if (isSearchPage) {
Navigation.navigate(
ROUTES.SEARCH_ROOT.getRoute({
query: buildCannedSearchQuery(),
}),
);
}
setSearchContext(false);
}, [onSearchQueryChange]);

const inputWidth = isFullWidth ? styles.w100 : {width: variables.popoverWidth};
Expand Down Expand Up @@ -258,7 +244,7 @@ function SearchAutocompleteInput({
selection={selection}
shouldShowClearButton={!!value && !isSearchingForReports}
shouldHideClearButton={false}
onClearInput={clearFilters}
onClearInput={clearInput}
/>
</View>
</Animated.View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {navigateToAndOpenReport} from '@libs/actions/Report';
import {setSearchContext} from '@libs/actions/Search';
import {mergeCardListWithWorkspaceFeeds} from '@libs/CardUtils';
import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import {getAllTaxRates} from '@libs/PolicyUtils';
import type {OptionData} from '@libs/ReportUtils';
import {getAutocompleteQueryWithComma, getQueryWithoutAutocompletedPart} from '@libs/SearchAutocompleteUtils';
import {buildUserReadableQueryString, getQueryWithUpdatedValues, isDefaultExpensesQuery, sanitizeSearchValue} from '@libs/SearchQueryUtils';
import {buildUserReadableQueryString, getQueryWithUpdatedValues, sanitizeSearchValue} from '@libs/SearchQueryUtils';
import StringUtils from '@libs/StringUtils';
import variables from '@styles/variables';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -66,14 +67,15 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo
const allCards = useMemo(() => mergeCardListWithWorkspaceFeeds(workspaceCardFeeds ?? CONST.EMPTY_OBJECT, userCardList), [userCardList, workspaceCardFeeds]);
const [allFeeds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER, {canBeMissing: true});
const {inputQuery: originalInputQuery} = queryJSON;
const isDefaultQuery = isDefaultExpensesQuery(queryJSON);
const [currentUserAccountID = -1] = useOnyx(ONYXKEYS.SESSION, {selector: accountIDSelector, canBeMissing: false});
const queryText = buildUserReadableQueryString(queryJSON, personalDetails, reports, taxRates, allCards, allFeeds, policies, currentUserAccountID, true);

// The actual input text that the user sees
const [textInputValue, setTextInputValue] = useState(isDefaultQuery ? '' : queryText);
const [searchContext] = useOnyx(ONYXKEYS.SEARCH_CONTEXT, {canBeMissing: true});
const shouldShowQuery = searchContext?.shouldShowSearchQuery ?? false;

const [textInputValue, setTextInputValue] = useState('');
// The input text that was last used for autocomplete; needed for the SearchAutocompleteList when browsing list via arrow keys
const [autocompleteQueryValue, setAutocompleteQueryValue] = useState(isDefaultQuery ? '' : queryText);
const [autocompleteQueryValue, setAutocompleteQueryValue] = useState('');
const [selection, setSelection] = useState({start: textInputValue.length, end: textInputValue.length});

const [autocompleteSubstitutions, setAutocompleteSubstitutions] = useState<SubstitutionMap>({});
Expand Down Expand Up @@ -107,9 +109,11 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo
}, [isFocused, registerSearchPageInput, displayNarrowHeader]);

useEffect(() => {
setTextInputValue(isDefaultQuery ? '' : queryText);
setAutocompleteQueryValue(isDefaultQuery ? '' : queryText);
}, [isDefaultQuery, queryText]);
const newValue = shouldShowQuery ? queryText : '';

setTextInputValue(newValue);
setAutocompleteQueryValue(newValue);
}, [queryText, shouldShowQuery]);

useEffect(() => {
const substitutionsMap = buildSubstitutionsMap(originalInputQuery, personalDetails, reports, taxRates, allCards, allFeeds, policies, currentUserAccountID);
Expand Down Expand Up @@ -204,6 +208,7 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo
return;
}

setSearchContext(true);
Navigation.navigate(
ROUTES.SEARCH_ROOT.getRoute({
query: updatedQuery,
Expand Down
2 changes: 2 additions & 0 deletions src/components/Search/SearchRouter/SearchRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import Navigation from '@navigation/Navigation';
import type {ReportsSplitNavigatorParamList} from '@navigation/types';
import variables from '@styles/variables';
import {navigateToAndOpenReport, searchInServer} from '@userActions/Report';
import {setSearchContext} from '@userActions/Search';
import CONST, {CONTINUATION_DETECTION_SEARCH_FILTER_KEYS} from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand Down Expand Up @@ -294,6 +295,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla

backHistory(() => {
onRouterClose();
setSearchContext(true);
Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query: updatedQuery}));
});

Expand Down
3 changes: 3 additions & 0 deletions src/hooks/useSearchTypeMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {PopoverMenuItem} from '@components/PopoverMenu';
import {useSearchContext} from '@components/Search/SearchContext';
import type {SearchQueryJSON} from '@components/Search/types';
import ThreeDotsMenu from '@components/ThreeDotsMenu';
import {setSearchContext} from '@libs/actions/Search';
import {mergeCardListWithWorkspaceFeeds} from '@libs/CardUtils';
import Navigation from '@libs/Navigation/Navigation';
import {getAllTaxRates} from '@libs/PolicyUtils';
Expand Down Expand Up @@ -119,6 +120,7 @@ export default function useSearchTypeMenu(queryJSON: SearchQueryJSON) {
return {
...baseMenuItem,
onSelected: () => {
setSearchContext(false);
Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query: item?.query ?? '', name: item?.name}));
},
rightComponent: (
Expand Down Expand Up @@ -191,6 +193,7 @@ export default function useSearchTypeMenu(queryJSON: SearchQueryJSON) {
containerStyle: isSelected ? [{backgroundColor: theme.border}] : undefined,
shouldCallAfterModalHide: true,
onSelected: singleExecution(() => {
setSearchContext(false);
Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query: item.searchQuery}));
}),
});
Expand Down
8 changes: 8 additions & 0 deletions src/libs/actions/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,13 @@ function updateAdvancedFilters(values: Nullable<Partial<FormOnyxValues<typeof ON
Onyx.merge(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, values);
}

/**
* Sets whether the search query should be displayed in the search input field
*/
function setSearchContext(shouldShowSearchQuery: boolean) {
Onyx.set(ONYXKEYS.SEARCH_CONTEXT, {shouldShowSearchQuery});
}

/**
* Clears all of the filters for a search
* NOTE: The source of truth for search filters is the 'q' param. You should never have to clear the form values when
Expand Down Expand Up @@ -1215,6 +1222,7 @@ export {
queueExportSearchWithTemplate,
updateAdvancedFilters,
clearAdvancedFilters,
setSearchContext,
deleteSavedSearch,
payMoneyRequestOnSearch,
approveMoneyRequestOnSearch,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/Search/SearchTypeMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import useSearchTypeMenuSections from '@hooks/useSearchTypeMenuSections';
import useSingleExecution from '@hooks/useSingleExecution';
import useSuggestedSearchDefaultNavigation from '@hooks/useSuggestedSearchDefaultNavigation';
import useThemeStyles from '@hooks/useThemeStyles';
import {setSearchContext} from '@libs/actions/Search';
import {mergeCardListWithWorkspaceFeeds} from '@libs/CardUtils';
import Navigation from '@libs/Navigation/Navigation';
import {getAllTaxRates} from '@libs/PolicyUtils';
Expand Down Expand Up @@ -109,6 +110,7 @@ function SearchTypeMenu({queryJSON}: SearchTypeMenuProps) {
return {
...baseMenuItem,
onPress: () => {
setSearchContext(false);
Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query: item?.query ?? '', name: item?.name}));
},
rightComponent: (
Expand Down Expand Up @@ -255,6 +257,7 @@ function SearchTypeMenu({queryJSON}: SearchTypeMenuProps) {

const onPress = singleExecution(() => {
clearSelectedTransactions();
setSearchContext(false);
Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query: item.searchQuery}));
});

Expand Down
7 changes: 7 additions & 0 deletions src/types/onyx/SearchContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** Model of the search context */
type SearchContext = {
/** Whether to show the search query in the input field */
shouldShowSearchQuery: boolean;
};

export default SearchContext;
2 changes: 2 additions & 0 deletions src/types/onyx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ import type ReviewDuplicates from './ReviewDuplicates';
import type {SaveSearch} from './SaveSearch';
import type ScheduleCallDraft from './ScheduleCallDraft';
import type ScreenShareRequest from './ScreenShareRequest';
import type SearchContext from './SearchContext';
import type SearchResults from './SearchResults';
import type SecurityGroup from './SecurityGroup';
import type SelectedTabRequest from './SelectedTabRequest';
Expand Down Expand Up @@ -278,6 +279,7 @@ export type {
DomainSettings,
SaveSearch,
RecentSearchItem,
SearchContext,
ImportedSpreadsheet,
ImportedSpreadsheetMemberData,
Onboarding,
Expand Down
Loading