diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 6a7a9b0d6885..73394f8e0edd 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -10463,6 +10463,7 @@ const CONST = { CONTROL_GROUP_CURRENCY: 'Insights-ControlGroupCurrency', CONTROL_GROUP_BY: 'Insights-ControlGroupBy', CONTROL_COMPARE: 'Insights-ControlCompare', + AI_EXPLAIN: 'Insights-AIExplain', DASHBOARD_TAB: 'Insights-DashboardTab', }, EXPENSE_RULES: { diff --git a/src/components/Search/SearchRouter/useAskConcierge.tsx b/src/components/Search/SearchRouter/useAskConcierge.tsx index 24bf63de801a..c8ab426716df 100644 --- a/src/components/Search/SearchRouter/useAskConcierge.tsx +++ b/src/components/Search/SearchRouter/useAskConcierge.tsx @@ -14,8 +14,11 @@ import {createTaskFromMarkdown} from '@userActions/Task'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import type {SidePanelContext} from '@src/types/onyx'; import type {FileObject} from '@src/types/utils/Attachment'; +import {getReportParentReportID} from '@selectors/Report'; + /** * Returns a callback that opens the side panel (or Concierge chat on native) * and sends the provided search query as a message. @@ -28,9 +31,9 @@ function useAskConcierge({forceConcierge = false}: {forceConcierge?: boolean} = const sidePanelReportID = useSidePanelReportID(); const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); const {openConciergeAnywhere, isInSidePanel} = useOpenConciergeAnywhere(); - const [sidePanelReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(sidePanelReportID)}`); + const [sidePanelParentReportID] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(sidePanelReportID)}`, {selector: getReportParentReportID}); - const isSidePanelOnConciergeThread = !!conciergeReportID && sidePanelReport?.parentReportID === conciergeReportID; + const isSidePanelOnConciergeThread = !!conciergeReportID && sidePanelParentReportID === conciergeReportID; const targetReportID = !forceConcierge && isInSidePanel && sidePanelReportID && !isSidePanelOnConciergeThread ? sidePanelReportID : conciergeReportID; const [targetReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(targetReportID)}`); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); @@ -42,7 +45,7 @@ function useAskConcierge({forceConcierge = false}: {forceConcierge?: boolean} = const shouldRespondInThread = targetReportID === conciergeReportID; - const askConcierge = (searchQuery: string) => { + const askConcierge = (searchQuery: string, sidePanelContext?: SidePanelContext) => { const trimmedQuery = searchQuery.trim(); if (!trimmedQuery || !shouldShowAskConcierge) { return; @@ -65,6 +68,7 @@ function useAskConcierge({forceConcierge = false}: {forceConcierge?: boolean} = currentUserAccountID, shouldPlaySound: true, isInSidePanel, + sidePanelContext, delegateAccountID, conciergeReportID, conciergeThreadReportID, diff --git a/src/languages/de.ts b/src/languages/de.ts index 158483845ede..0c3060537183 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -1233,6 +1233,8 @@ const translations: TranslationDeepObject = { }, compliance: 'Compliance', runningTotal: 'Laufende Summe', + explain: 'Erklären', + explainChartPrompt: (chartTitle: string) => `Erklären Sie die Daten in ${chartTitle}.`, }, allSettingsScreen: { subscription: 'Abonnement', diff --git a/src/languages/el.ts b/src/languages/el.ts index ad11bee9730d..022ff0369c99 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -1277,6 +1277,8 @@ const translations: TranslationDeepObject = { }, compliance: 'Συμμόρφωση', runningTotal: 'Τρέχον σύνολο', + explain: 'Επεξήγηση', + explainChartPrompt: (chartTitle: string) => `Εξηγήστε τα δεδομένα στο ${chartTitle}.`, }, allSettingsScreen: { subscription: 'Συνδρομή', diff --git a/src/languages/en.ts b/src/languages/en.ts index f7e39b9867c4..33a63f018ac5 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1347,6 +1347,8 @@ const translations = { }, insightsPage: { viewOnSpend: 'View on Spend', + explain: 'Explain', + explainChartPrompt: (chartTitle: string) => `Explain the data in ${chartTitle}.`, compliance: 'Compliance', runningTotal: 'Running total', compare: { diff --git a/src/languages/es.ts b/src/languages/es.ts index f87ced82ef71..1ea744a4a2a6 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1225,6 +1225,8 @@ const translations: TranslationDeepObject = { }, compliance: 'Cumplimiento', runningTotal: 'Total acumulado', + explain: 'Explicar', + explainChartPrompt: (chartTitle: string) => `Explica los datos en ${chartTitle}.`, }, allSettingsScreen: { subscription: 'Suscripcion', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 7b3758ca194a..d49debd7e9b1 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -1237,6 +1237,8 @@ const translations: TranslationDeepObject = { }, compliance: 'Conformité', runningTotal: 'Total cumulé', + explain: 'Expliquer', + explainChartPrompt: (chartTitle: string) => `Expliquez les données dans ${chartTitle}.`, }, allSettingsScreen: { subscription: 'Abonnement', diff --git a/src/languages/it.ts b/src/languages/it.ts index 4d2dea72656f..2798d3992782 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -1233,6 +1233,8 @@ const translations: TranslationDeepObject = { }, compliance: 'Conformità', runningTotal: 'Totale progressivo', + explain: 'Spiega', + explainChartPrompt: (chartTitle: string) => `Spiega i dati in ${chartTitle}.`, }, allSettingsScreen: { subscription: 'Abbonamento', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index 494395f89851..affa80719962 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -1221,6 +1221,8 @@ const translations: TranslationDeepObject = { }, compliance: 'コンプライアンス', runningTotal: '累計合計', + explain: '説明', + explainChartPrompt: (chartTitle: string) => `${chartTitle} のデータを説明します。`, }, allSettingsScreen: { subscription: 'サブスクリプション', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 0b73dbfe5dc6..9080d98a2369 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -1232,6 +1232,8 @@ const translations: TranslationDeepObject = { }, compliance: 'Naleving', runningTotal: 'Doorlopend totaal', + explain: 'Uitleg', + explainChartPrompt: (chartTitle: string) => `Leg de gegevens in ${chartTitle} uit.`, }, allSettingsScreen: { subscription: 'Abonnement', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index 47dabff9cc37..47eeedba9a58 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -1256,6 +1256,8 @@ const translations: TranslationDeepObject = { }, compliance: 'Zgodność', runningTotal: 'Suma narastająco', + explain: 'Wyjaśnij', + explainChartPrompt: (chartTitle: string) => `Wyjaśnij dane w ${chartTitle}.`, }, allSettingsScreen: { subscription: 'Subskrypcja', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index f21e24a35e26..6164ff289118 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -1232,6 +1232,8 @@ const translations: TranslationDeepObject = { }, compliance: 'Conformidade', runningTotal: 'Total acumulado', + explain: 'Explicar', + explainChartPrompt: (chartTitle: string) => `Explique os dados em ${chartTitle}.`, }, allSettingsScreen: { subscription: 'Assinatura', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 7438ab18ce78..0ee55840101f 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -1186,6 +1186,8 @@ const translations: TranslationDeepObject = { }, compliance: '合规', runningTotal: '累计总额', + explain: '解释', + explainChartPrompt: (chartTitle: string) => `解释「${chartTitle}」中的数据。`, }, allSettingsScreen: { subscription: '订阅', diff --git a/src/pages/Insights/InsightsDashboard.tsx b/src/pages/Insights/InsightsDashboard.tsx index c6be7f9cea2d..cd5bccc05fd4 100644 --- a/src/pages/Insights/InsightsDashboard.tsx +++ b/src/pages/Insights/InsightsDashboard.tsx @@ -30,7 +30,7 @@ import variables from '@styles/variables'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {AIInsight, InsightsDashboard as InsightsDashboardRecord, InsightsDashboardID} from '@src/types/onyx'; +import type {AIInsight, InsightsDashboard as InsightsDashboardRecord, InsightsDashboardID, InsightsScope} from '@src/types/onyx'; import viewRef from '@src/types/utils/viewRef'; import type {OnyxCollection} from 'react-native-onyx'; @@ -61,6 +61,7 @@ import useInsightsFilters from './useInsightsFilters'; type InsightsDashboardContentProps = { state: InsightsDashboardState; aiInsights: AIInsight[] | undefined; + insightsScope: InsightsScope; isLoadingAIInsights: boolean; headlineChart: InsightsDashboardChart; @@ -86,6 +87,7 @@ type InsightsDashboardContentProps = { function InsightsDashboardContent({ state, aiInsights, + insightsScope, isLoadingAIInsights, headlineChart, supportingCharts, @@ -222,6 +224,7 @@ function InsightsDashboardContent({ {isBetaEnabled(CONST.BETAS.INSIGHTS_AI) && ( )} @@ -234,6 +237,7 @@ function InsightsDashboardContent({ averageTotal={headlineChart.averageTotal} isDashboardLoaded={headlineChart.isDashboardLoaded} filters={filters} + insightsScope={insightsScope} onRetry={onRetry} onGroupByChange={onGroupByChange} /> @@ -255,6 +259,7 @@ function InsightsDashboardContent({ averageTotal={averageTotal} isDashboardLoaded={isDashboardLoaded} filters={filters} + insightsScope={insightsScope} onRetry={onRetry} /> ))} @@ -408,6 +413,12 @@ function InsightsDashboard({dashboardID, accessibleDashboards}: {dashboardID: In + {insight.text} + ); } diff --git a/src/pages/Insights/ai/InsightsAICardRow.tsx b/src/pages/Insights/ai/InsightsAICardRow.tsx index 4533cca7b5d2..a844c58f8382 100644 --- a/src/pages/Insights/ai/InsightsAICardRow.tsx +++ b/src/pages/Insights/ai/InsightsAICardRow.tsx @@ -6,7 +6,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import {hasHoverSupport} from '@libs/DeviceCapabilities'; -import type {AIInsight} from '@src/types/onyx'; +import type {AIInsight, InsightsScope} from '@src/types/onyx'; import type {ReactNode} from 'react'; @@ -21,12 +21,15 @@ const SKELETON_CARD_COUNT = 4; type InsightsAICardRowProps = { insights: AIInsight[] | undefined; + /** Dashboard filters the insights were written for, sent to Concierge when the user asks to explain. */ + insightsScope: InsightsScope; + /** Whether the dashboard has no response for the current filters yet */ isLoading: boolean; }; /** Shows the AI insights in a sideways-scrolling row, with placeholders while the dashboard loads. */ -function InsightsAICardRow({insights, isLoading}: InsightsAICardRowProps) { +function InsightsAICardRow({insights, insightsScope, isLoading}: InsightsAICardRowProps) { const styles = useThemeStyles(); const {shouldUseNarrowLayout} = useResponsiveLayout(); const {pageGutter, pageGutterEdgeToEdge} = useLayoutSpacing(); @@ -51,7 +54,15 @@ function InsightsAICardRow({insights, isLoading}: InsightsAICardRowProps) { > {isLoading ? Array.from({length: SKELETON_CARD_COUNT}, (item, index) => renderWithDivider(, index)) - : insights?.map((insight, index) => renderWithDivider(, index))} + : insights?.map((insight, index) => + renderWithDivider( + , + index, + ), + )} ); } diff --git a/src/pages/Insights/ai/InsightsAICardSkeleton.tsx b/src/pages/Insights/ai/InsightsAICardSkeleton.tsx index 307e2d66fdbf..93c879ccd704 100644 --- a/src/pages/Insights/ai/InsightsAICardSkeleton.tsx +++ b/src/pages/Insights/ai/InsightsAICardSkeleton.tsx @@ -13,13 +13,17 @@ const LINE_HEIGHT = variables.lineHeightSizeH2; const BAR_HEIGHT = 16; const BAR_OFFSET_Y = (LINE_HEIGHT - BAR_HEIGHT) / 2; +const BUTTON_HEIGHT = variables.componentSizeSmall; +const BUTTON_BAR_WIDTH = 48; +const BUTTON_BAR_HEIGHT = 8; + /** Stands in for an AI card's narration while the dashboard loads. */ function InsightsAICardSkeleton() { const styles = useThemeStyles(); const theme = useTheme(); return ( - + + + + ); } diff --git a/src/pages/Insights/ai/InsightsExplainButton.tsx b/src/pages/Insights/ai/InsightsExplainButton.tsx new file mode 100644 index 000000000000..63353856128e --- /dev/null +++ b/src/pages/Insights/ai/InsightsExplainButton.tsx @@ -0,0 +1,58 @@ +import Button from '@components/Button'; +import useAskConcierge from '@components/Search/SearchRouter/useAskConcierge'; + +import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; +import useLocalize from '@hooks/useLocalize'; +import useTheme from '@hooks/useTheme'; +import useThemeStyles from '@hooks/useThemeStyles'; + +import CONST from '@src/CONST'; +import type {InsightsScope} from '@src/types/onyx'; + +import React from 'react'; + +type InsightsExplainButtonProps = { + /** Message sent to Concierge on press */ + explainPrompt: string; + + /** Dashboard and filters sent with the prompt so Concierge explains the data the user sees */ + insightsScope: InsightsScope; + + /** Tints the glyph and label with the link color instead of the muted one */ + isAccented?: boolean; +}; + +/** Asks Concierge to explain an AI insight or chart, sending along the dashboard filters so the answer covers the data on screen. */ +function InsightsExplainButton({explainPrompt, insightsScope, isAccented = false}: InsightsExplainButtonProps) { + const styles = useThemeStyles(); + const theme = useTheme(); + const {translate} = useLocalize(); + const icons = useMemoizedLazyExpensifyIcons(['Sparkles']); + const {askConcierge, shouldShowAskConcierge} = useAskConcierge({forceConcierge: true}); + + if (!shouldShowAskConcierge) { + return null; + } + + const glyphColor = isAccented ? theme.link : theme.icon; + + return ( + + ); +} + +export default InsightsExplainButton; diff --git a/src/pages/Insights/charts/InsightsChartWidget.tsx b/src/pages/Insights/charts/InsightsChartWidget.tsx index 08bc221686d5..e2c96ff99060 100644 --- a/src/pages/Insights/charts/InsightsChartWidget.tsx +++ b/src/pages/Insights/charts/InsightsChartWidget.tsx @@ -12,6 +12,7 @@ import {useCurrencyListActions} from '@hooks/useCurrencyList'; import useLayoutSpacing from '@hooks/useLayoutSpacing'; import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; import useLocalize from '@hooks/useLocalize'; +import usePermissions from '@hooks/usePermissions'; import useThemeStyles from '@hooks/useThemeStyles'; import localFileDownload from '@libs/localFileDownload'; @@ -19,6 +20,7 @@ import Navigation from '@libs/Navigation/Navigation'; import {INSIGHTS_CHART_STATE} from '@libs/resolveInsightsChartData'; import {getDateFilterRange} from '@libs/SearchQueryUtils'; +import InsightsExplainButton from '@pages/Insights/ai/InsightsExplainButton'; import buildInsightsChartCSV from '@pages/Insights/buildInsightsChartCSV'; import InsightsGroupByDropdown from '@pages/Insights/controls/InsightsGroupByDropdown'; import type {InsightsChartSpec} from '@pages/Insights/dashboardSpecs'; @@ -29,7 +31,7 @@ import useInsightsChartData from '@pages/Insights/useInsightsChartData'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; -import type {SearchResults} from '@src/types/onyx'; +import type {InsightsScope, SearchResults} from '@src/types/onyx'; import type {OnyxEntry} from 'react-native-onyx'; @@ -64,6 +66,9 @@ type InsightsChartWidgetProps = { /** Page-level filters every chart on the dashboard is narrowed by */ filters: InsightsFilters; + /** Dashboard filters sent to Concierge when the user asks to explain the chart */ + insightsScope: InsightsScope; + /** Called by the retry button to request the dashboard again */ onRetry: () => void; @@ -80,11 +85,13 @@ function InsightsChartWidget({ averageTotal, isDashboardLoaded, filters, + insightsScope, onRetry, onGroupByChange, }: InsightsChartWidgetProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); + const {isBetaEnabled} = usePermissions(); const {cardPaddingHorizontal, cardPaddingBottom} = useLayoutSpacing(); const icons = useMemoizedLazyExpensifyIcons(['Expand', 'Table']); const {getCurrencyDecimals} = useCurrencyListActions(); @@ -127,6 +134,14 @@ function InsightsChartWidget({ /> ) : null; + const explainButton = + isBetaEnabled(CONST.BETAS.INSIGHTS_AI) && (state === INSIGHTS_CHART_STATE.READY || isLoading) ? ( + + ) : null; + const headerMenu = !!queryJSON && (state === INSIGHTS_CHART_STATE.READY || isLoading) ? ( {groupByControl} + {explainButton} {headerMenu} ) : null diff --git a/src/types/onyx/SidePanel.tsx b/src/types/onyx/SidePanel.tsx index df9648f8c666..7d60c522b732 100644 --- a/src/types/onyx/SidePanel.tsx +++ b/src/types/onyx/SidePanel.tsx @@ -1,3 +1,7 @@ +import type {InsightsFilters} from '@pages/Insights/insightsFilters'; + +import type {InsightsSearchKey} from './InsightsDashboard'; + type SidePanel = { /** Whether the Side Panel is open on large screens */ open: boolean; @@ -12,11 +16,16 @@ type SidePanel = { reportID?: string; }; +/** Insights dashboard and filters the user was looking at when they asked Concierge about it */ +type InsightsScope = Pick & { + searchKey: InsightsSearchKey; +}; + /** * Describes the context of what the user was viewing when they sent a message from the Side Panel. * Sent to the backend so Concierge can tailor its response to the user's current context. */ -type SidePanelContext = {reportID?: string; selectedTransactionIDs?: string; selectedReportIDs?: string}; +type SidePanelContext = {reportID?: string; selectedTransactionIDs?: string; selectedReportIDs?: string; insightsScope?: InsightsScope}; export default SidePanel; -export type {SidePanelContext}; +export type {InsightsScope, SidePanelContext}; diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index 67c1002badc9..bab09d0e6460 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -228,7 +228,7 @@ import type Session from './Session'; import type ShareBankAccount from './ShareBankAccount'; import type ShareTempFile from './ShareTempFile'; import type SidePanel from './SidePanel'; -import type {SidePanelContext} from './SidePanel'; +import type {InsightsScope, SidePanelContext} from './SidePanel'; import type StripeCustomerID from './StripeCustomerID'; import type SuggestedAgent from './SuggestedAgent'; import type SuggestedAgentRule from './SuggestedAgentRule'; @@ -515,6 +515,7 @@ export type { EnableGlobalReimbursementsModal, SidePanel, SidePanelContext, + InsightsScope, LastPaymentMethodType, ReportAttributesDerivedValue, LastSearchParams, diff --git a/tests/ui/InsightsChartWidgetTest.tsx b/tests/ui/InsightsChartWidgetTest.tsx index 11e9d59dfe53..da004346567f 100644 --- a/tests/ui/InsightsChartWidgetTest.tsx +++ b/tests/ui/InsightsChartWidgetTest.tsx @@ -62,6 +62,7 @@ function renderWidget() { averageTotal={undefined} isDashboardLoaded={undefined} filters={FILTERS} + insightsScope={{searchKey: INSIGHTS_DASHBOARD_SPECS[CONST.INSIGHTS.DASHBOARD.SPEND].searchKey, policyIDs: [], date: FILTERS.date, groupCurrency: FILTERS.groupCurrency}} onRetry={jest.fn()} /> , diff --git a/tests/unit/hooks/useAskConcierge.test.tsx b/tests/unit/hooks/useAskConcierge.test.tsx index 32df52a43f45..bad56a07ee51 100644 --- a/tests/unit/hooks/useAskConcierge.test.tsx +++ b/tests/unit/hooks/useAskConcierge.test.tsx @@ -5,12 +5,15 @@ import useAskConcierge from '@components/Search/SearchRouter/useAskConcierge'; import {addAttachmentWithComment, addComment} from '@userActions/Report'; import {createTaskFromMarkdown} from '@userActions/Task'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Report} from '@src/types/onyx'; import type {FileObject} from '@src/types/utils/Attachment'; import Onyx from 'react-native-onyx'; +import waitForBatchedUpdates from '../../utils/waitForBatchedUpdates'; + const ACCOUNT_ID = 1; const DELEGATE_ACCOUNT_ID = '99'; const TIMEZONE = 'Europe/Warsaw'; @@ -119,6 +122,29 @@ describe('useAskConcierge', () => { expect(result.current.conciergeTargetReportID).toBe(CONCIERGE_REPORT_ID); }); + it('does not rerender when the thread open in the side panel gets a reply', async () => { + // Given web, with the side panel showing the thread of an earlier Concierge question + mockIsInSidePanel = true; + await seedReports(); + const conciergeThread = {reportID: '300', parentReportID: CONCIERGE_REPORT_ID} as Report; + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${conciergeThread.reportID}`, conciergeThread); + mockSidePanelReportID = conciergeThread.reportID; + let renderCount = 0; + renderHook(() => { + renderCount++; + return useAskConcierge(); + }); + await waitForBatchedUpdates(); + const renderCountBeforeReply = renderCount; + + // When Concierge replies in that thread + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${conciergeThread.reportID}`, {lastMessageText: 'Spend is up because of travel.'}); + await waitForBatchedUpdates(); + + // Then the hook does not rerender, since the reply leaves the thread's parent, and so the target, unchanged + expect(renderCount).toBe(renderCountBeforeReply); + }); + it('targets Concierge on native, where there is no side panel', async () => { // Given native, which has no side panel to route through await seedReports(); @@ -161,6 +187,21 @@ describe('useAskConcierge', () => { ); }); + it('sends the side panel context with the comment, so Concierge answers about the data on screen', async () => { + // Given a loaded Concierge report and the Insights filters the user is looking at + await seedReports(); + const {result} = renderAskConcierge({forceConcierge: true}); + const sidePanelContext = { + insightsScope: {searchKey: CONST.INSIGHTS.SEARCH_KEY.SPEND, policyIDs: ['ABC123'], date: {from: '2026-01-01', to: '2026-03-31'}, groupCurrency: CONST.CURRENCY.USD}, + }; + + // When the user asks Concierge to explain an insight + result.current.askConcierge('Explain the data in Spend over time', sidePanelContext); + + // Then the filters reach addComment alongside the message + expect(mockAddComment).toHaveBeenCalledWith(expect.objectContaining({text: 'Explain the data in Spend over time', sidePanelContext})); + }); + it('creates a task instead of a comment when the message uses the `[] task` shorthand', async () => { // Given a loaded Concierge report and text that the markdown task detection claims await seedReports();