@@ -2,30 +2,33 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
22import useDelegateAccountID from '@hooks/useDelegateAccountID' ;
33import useOnyx from '@hooks/useOnyx' ;
44import useOpenConciergeAnywhere from '@hooks/useOpenConciergeAnywhere' ;
5+ import useSidePanelReportID from '@hooks/useSidePanelReportID' ;
56import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID' ;
67import { addComment } from '@userActions/Report' ;
78import CONST from '@src/CONST' ;
89import ONYXKEYS from '@src/ONYXKEYS' ;
910
1011/**
11- * Returns a callback that opens Concierge ( side panel on web, chat on native)
12+ * Returns a callback that opens the side panel (or Concierge chat on native)
1213 * and sends the provided search query as a message.
1314 */
1415function useAskConcierge ( ) {
16+ const sidePanelReportID = useSidePanelReportID ( ) ;
1517 const [ conciergeReportID ] = useOnyx ( ONYXKEYS . CONCIERGE_REPORT_ID ) ;
16- const [ conciergeReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ getNonEmptyStringOnyxID ( conciergeReportID ) } ` ) ;
17- const { timezone, accountID : currentUserAccountID } = useCurrentUserPersonalDetails ( ) ;
1818 const { openConciergeAnywhere, isInSidePanel} = useOpenConciergeAnywhere ( ) ;
19+ const targetReportID = ( isInSidePanel ? sidePanelReportID : undefined ) ?? conciergeReportID ;
20+ const [ targetReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ getNonEmptyStringOnyxID ( targetReportID ) } ` ) ;
21+ const { timezone, accountID : currentUserAccountID } = useCurrentUserPersonalDetails ( ) ;
1922 const delegateAccountID = useDelegateAccountID ( ) ;
2023
2124 return ( searchQuery : string ) => {
2225 openConciergeAnywhere ( ) ;
23- if ( ! conciergeReport || ! conciergeReportID ) {
26+ if ( ! targetReport || ! targetReportID ) {
2427 return ;
2528 }
2629 addComment ( {
27- report : conciergeReport ,
28- notifyReportID : conciergeReportID ,
30+ report : targetReport ,
31+ notifyReportID : targetReportID ,
2932 ancestors : [ ] ,
3033 text : searchQuery ,
3134 timezoneParam : timezone ?? CONST . DEFAULT_TIME_ZONE ,
0 commit comments