Skip to content

Commit 02461ab

Browse files
authored
Merge pull request #89580 from software-mansion-labs/fix/hide-ask-concierge-until-loaded
Don't show "Ask Concierge" in search router until the report is loaded
2 parents 5c1ebfc + e310914 commit 02461ab

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

src/components/Search/SearchRouter/SearchRouter.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
7575
const {shouldUseNarrowLayout} = useResponsiveLayout();
7676
const listRef = useRef<SelectionListWithSectionsHandle>(null);
7777
const expensifyIcons = useMemoizedLazyExpensifyIcons(['MagnifyingGlass', 'ConciergeAvatar']);
78-
const askConcierge = useAskConcierge();
78+
const {askConcierge, shouldShowAskConcierge} = useAskConcierge();
7979

8080
// The actual input text that the user sees
8181
const [textInputValue, , setTextInputValue] = useDebouncedState('', 500);
@@ -211,15 +211,19 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
211211
keyForList: CONST.SEARCH.SEARCH_ROUTER_ITEM_TYPE.FIND_ITEM,
212212
searchItemType: CONST.SEARCH.SEARCH_ROUTER_ITEM_TYPE.SEARCH,
213213
},
214-
{
215-
text: translate('search.askConcierge', textInputValue),
216-
singleIcon: expensifyIcons.ConciergeAvatar,
217-
shouldIconApplyFill: false,
218-
searchQuery: textInputValue,
219-
itemStyle: styles.activeComponentBG,
220-
keyForList: CONST.SEARCH.SEARCH_ROUTER_ITEM_TYPE.ASK_CONCIERGE,
221-
searchItemType: CONST.SEARCH.SEARCH_ROUTER_ITEM_TYPE.ASK_CONCIERGE,
222-
},
214+
...(shouldShowAskConcierge
215+
? [
216+
{
217+
text: translate('search.askConcierge', textInputValue),
218+
singleIcon: expensifyIcons.ConciergeAvatar,
219+
shouldIconApplyFill: false,
220+
searchQuery: textInputValue,
221+
itemStyle: styles.activeComponentBG,
222+
keyForList: CONST.SEARCH.SEARCH_ROUTER_ITEM_TYPE.ASK_CONCIERGE,
223+
searchItemType: CONST.SEARCH.SEARCH_ROUTER_ITEM_TYPE.ASK_CONCIERGE,
224+
},
225+
]
226+
: []),
223227
]
224228
: undefined;
225229

src/components/Search/SearchRouter/useAskConcierge.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
1111
/**
1212
* Returns a callback that opens the side panel (or Concierge chat on native)
1313
* and sends the provided search query as a message.
14+
* Also returns a flag indicating whether the Ask Concierge item is ready to be displayed.
1415
*/
1516
function useAskConcierge() {
1617
const sidePanelReportID = useSidePanelReportID();
@@ -20,13 +21,14 @@ function useAskConcierge() {
2021
const [targetReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(targetReportID)}`);
2122
const {timezone, accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
2223
const delegateAccountID = useDelegateAccountID();
24+
const shouldShowAskConcierge = !!targetReportID && !!targetReport;
2325

24-
return (searchQuery: string) => {
25-
openConciergeAnywhere();
26+
const askConcierge = (searchQuery: string) => {
2627
const trimmedQuery = searchQuery.trim();
27-
if (!trimmedQuery || !targetReport || !targetReportID) {
28+
if (!trimmedQuery || !shouldShowAskConcierge) {
2829
return;
2930
}
31+
openConciergeAnywhere();
3032
addComment({
3133
report: targetReport,
3234
notifyReportID: targetReportID,
@@ -39,6 +41,8 @@ function useAskConcierge() {
3941
delegateAccountID,
4042
});
4143
};
44+
45+
return {askConcierge, shouldShowAskConcierge};
4246
}
4347

4448
export default useAskConcierge;

0 commit comments

Comments
 (0)