@@ -49,6 +49,7 @@ import {getQueryWithSubstitutions} from './getQueryWithSubstitutions';
4949import { getUpdatedSubstitutionsMap } from './getUpdatedSubstitutionsMap' ;
5050import { getContextualReportData , getContextualSearchAutocompleteKey , getContextualSearchQuery } from './SearchRouterUtils' ;
5151import updateAutocompleteSubstitutionsForSelection from './updateAutocompleteSubstitutionsForSelection' ;
52+ import useAskConcierge from './useAskConcierge' ;
5253
5354const privateIsArchivedSelector = ( nvp : { private_isArchived ?: string } | undefined ) : boolean | undefined => ! ! nvp ?. private_isArchived ;
5455
@@ -72,7 +73,8 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
7273 const personalDetails = usePersonalDetails ( ) ;
7374 const { shouldUseNarrowLayout} = useResponsiveLayout ( ) ;
7475 const listRef = useRef < SelectionListWithSectionsHandle > ( null ) ;
75- const expensifyIcons = useMemoizedLazyExpensifyIcons ( [ 'MagnifyingGlass' ] ) ;
76+ const expensifyIcons = useMemoizedLazyExpensifyIcons ( [ 'MagnifyingGlass' , 'ConciergeAvatar' ] ) ;
77+ const askConcierge = useAskConcierge ( ) ;
7678
7779 // The actual input text that the user sees
7880 const [ textInputValue , , setTextInputValue ] = useDebouncedState ( '' , 500 ) ;
@@ -198,15 +200,26 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
198200 ] ,
199201 ) ;
200202
201- const searchQueryItem = textInputValue
202- ? {
203- text : textInputValue ,
204- singleIcon : expensifyIcons . MagnifyingGlass ,
205- searchQuery : textInputValue ,
206- itemStyle : styles . activeComponentBG ,
207- keyForList : CONST . SEARCH . SEARCH_ROUTER_ITEM_TYPE . FIND_ITEM ,
208- searchItemType : CONST . SEARCH . SEARCH_ROUTER_ITEM_TYPE . SEARCH ,
209- }
203+ const searchQueryItems = textInputValue
204+ ? [
205+ {
206+ text : textInputValue ,
207+ singleIcon : expensifyIcons . MagnifyingGlass ,
208+ searchQuery : textInputValue ,
209+ itemStyle : styles . activeComponentBG ,
210+ keyForList : CONST . SEARCH . SEARCH_ROUTER_ITEM_TYPE . FIND_ITEM ,
211+ searchItemType : CONST . SEARCH . SEARCH_ROUTER_ITEM_TYPE . SEARCH ,
212+ } ,
213+ {
214+ text : translate ( 'search.askConcierge' , textInputValue ) ,
215+ singleIcon : expensifyIcons . ConciergeAvatar ,
216+ shouldIconApplyFill : false ,
217+ searchQuery : textInputValue ,
218+ itemStyle : styles . activeComponentBG ,
219+ keyForList : CONST . SEARCH . SEARCH_ROUTER_ITEM_TYPE . ASK_CONCIERGE ,
220+ searchItemType : CONST . SEARCH . SEARCH_ROUTER_ITEM_TYPE . ASK_CONCIERGE ,
221+ } ,
222+ ]
210223 : undefined ;
211224
212225 const shouldScrollRef = useRef ( false ) ;
@@ -308,6 +321,12 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
308321 setAutocompleteSubstitutions,
309322 } ) ;
310323 setFocusAndScrollToRight ( ) ;
324+ } else if ( item . searchItemType === CONST . SEARCH . SEARCH_ROUTER_ITEM_TYPE . ASK_CONCIERGE ) {
325+ const { searchQuery} = item ;
326+ backHistory ( ( ) => {
327+ askConcierge ( searchQuery ) ;
328+ } ) ;
329+ onRouterClose ( ) ;
311330 } else {
312331 submitSearch ( item . searchQuery , item . keyForList !== CONST . SEARCH . SEARCH_ROUTER_ITEM_TYPE . FIND_ITEM ) ;
313332 }
@@ -335,13 +354,14 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
335354 betas ,
336355 contextualPoliciesMap ,
337356 contextualReportsMap ,
357+ askConcierge ,
338358 ] ,
339359 ) ;
340360
341361 useKeyboardShortcut ( CONST . KEYBOARD_SHORTCUTS . ESCAPE , ( ) => {
342362 onRouterClose ( ) ;
343363 } ) ;
344- const updateAndScrollToFocusedIndex = useCallback ( ( ) => listRef . current ?. updateAndScrollToFocusedIndex ( 1 , true ) , [ ] ) ;
364+ const updateAndScrollToFocusedIndex = useCallback ( ( ) => listRef . current ?. updateAndScrollToFocusedIndex ( searchQueryItems ?. length ?? 1 , true ) , [ searchQueryItems ?. length ] ) ;
345365
346366 const modalWidth = shouldUseNarrowLayout ? styles . w100 : { width : variables . searchRouterPopoverWidth } ;
347367
@@ -387,7 +407,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
387407 < DeferredAutocompleteList
388408 autocompleteQueryValue = { autocompleteQueryValue || textInputValue }
389409 handleSearch = { searchInServer }
390- searchQueryItem = { searchQueryItem }
410+ searchQueryItems = { searchQueryItems }
391411 getAdditionalSections = { getAdditionalSections }
392412 onListItemPress = { onListItemPress }
393413 onHighlightFirstItem = { updateAndScrollToFocusedIndex }
0 commit comments