App icon indicating copy to clipboard operation
App copied to clipboard

[$175] Concierge - “Export my last report to PDF” is displayed for a new user who has no expenses or reports

Open izarutskaya opened this issue 3 weeks ago • 21 comments

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.33-1 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: @dylanexpensify Slack conversation (hyperlinked to channel name): #expensify_bugs

Action Performed:

  1. User signs up with public email
  2. Adds work email
  3. Selects Track expenses for business
  4. Enters personal details
  5. Completes onboarding and is dropped on Home page
  6. Clicks on Concierge

Expected Result:

Suggested input is something the user can actually do

Actual Result:

Input suggests something the user can’t do

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • [ ] Android: App
  • [ ] Android: mWeb Chrome
  • [x] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [ ] Windows: Chrome
  • [ ] MacOS: Chrome / Safari

Screenshots/Videos

https://github.com/user-attachments/assets/67770ae9-3c03-4593-ae88-3cc1f0a766e3

View all open jobs on GitHub

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @ahmedGaber93

izarutskaya avatar Nov 07 '26 16:11 izarutskaya

Triggered auto assignment to Contributor-plus team member for initial proposal review - @mkhutornyi (External)

melvin-bot[bot] avatar Nov 07 '26 17:11 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022119113137106152581

melvin-bot[bot] avatar Nov 07 '26 17:11 melvin-bot[bot]

🤖 Web test steps verification results: ⚠️ partial

The web account had no expenses or reports, but Concierge displayed a different suggestion. Code inspection confirms that the PDF prompt can be selected without checking report availability; the exact reported onboarding flow was not reproduced.

Reports empty state showing No reports yet
Step Status
1. Sign up using a public emailThe provided session was authenticated with a Gmail account. Sign-up was not independently observed or repeated.
✅
2. Add a work emailNot established: session setup skipped this step.
⚠️
3. Select Track expenses for businessNot established: session setup selected “Something else.”
⚠️
4. Enter personal detailsSession setup entered generic details; this step was not independently observed.
⚠️
5. Complete onboarding and land on HomeThe initial live screen showed authenticated Home.
✅
6. Open ConciergeOpened the main Concierge conversation. Its empty composer displayed “What drove my spend last quarter?”
Concierge empty conversation with a spending-analysis placeholder
✅
Verify no expenses or expense reports existExpenses showed “No expenses yet”; Reports showed “No reports yet,” without search queries.
Reports empty state showing No reports yet
✅
Verify the PDF prompt appearsThe exact prompt did not appear in this session. Selection happens once per composer mount, so one different suggestion does not disprove the issue.
⚠️
Inspect suggestion selection — structured proposal

Proposal

What is the root cause of that problem?

Medium confidence: ComposerInput.tsx:36–105 randomly selects from 15 unconditional placeholder keys, including the PDF prompt. The Concierge branch renders that selection without checking expense reports. The Concierge check only identifies the main conversation and excludes the side panel. This is placeholder text—not an export action or a server-generated suggestion.

What changes do you think we should make in order to solve the problem?

Filter candidate placeholders by their prerequisites. Exclude the PDF prompt when no eligible report is available; use a safe fallback while eligibility is unknown. Revalidate the selected placeholder when report data changes, rather than checking only at mount. Review other history-dependent prompts too—the spending-analysis prompt observed here has the same new-user mismatch.

Regression coverage: Force the PDF selection deterministically; test chat-only accounts, eligible reports, delayed report loading, and report removal.

What alternative solutions did you explore?

Gating by email domain or onboarding intent would not establish report availability. Permanently removing the PDF prompt would also hide it from users who can use it. Production logs are unnecessary to establish this client-side selection defect; exact runtime reproduction remains unconfirmed.
✅

Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/106297) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.


view run

MelvinBot avatar Nov 07 '26 17:11 MelvinBot

Proposal

What is the root cause of that problem?

In src/pages/inbox/report/ReportActionCompose/ComposerInput.tsx, the Concierge DM placeholder is picked once per mount at line 90 (useState(() => ASK_CONCIERGE_PLACEHOLDER_KEYS[Math.floor(Math.random() * ...length)])) from the static list at lines 36-52. That list contains history-dependent prompts, including common.concierge.composerPlaceholders.exportPdf (line 49), exportCsv, awaitingApproval and unsubmitted. The isConciergeInboxDM branch then renders the pick with no check that the user has any report or expense. A brand-new user can therefore be shown "Export my last report to PDF" when there is nothing to export.

What changes do you think we should make in order to solve the problem?

Filter the candidate keys by the user's data before picking one. Add a small helper in ComposerInput.tsx that returns the keys for the current state. When the user has no expense report, it drops the report-dependent keys (exportPdf, exportCsv, awaitingApproval, notReimbursed, unsubmitted, leftToPay, combineExpenses). Use a cheap check such as an ONYXKEYS.COLLECTION.REPORT selector that looks for any isMoneyRequestReport. Keep the generic prompts (askConciergeForHelp, createExpense) as the fallback, so the list is never empty.

Because useState fixes the pick on first render and Onyx may still be loading, compute the pick with useMemo keyed on hasExpenseReports. Keep the random index in a useRef so the placeholder does not flicker on every Onyx update.

Test: a unit test for the helper, with Math.random mocked to select exportPdf. With no expense reports the result must not contain exportPdf. With one expense report it must still be allowed.

What alternative solutions did you explore? (Optional)

MelvinBot's proposal (the only one in the thread) reaches the same root cause. It suggests filtering by prerequisites, and it also proposes revalidating when data changes. Mine differs in two ways. It names a concrete rule (no expense report removes the report-dependent keys) and a stable way to avoid flicker (the ref). It also adds the test that drives the random pick. Gating by email domain or onboarding intent would not reflect whether reports exist. Removing the PDF prompt outright would hide it from users who can use it.

Stephen3453 avatar Nov 07 '26 17:11 Stephen3453

@mkhutornyi — I'd like to be considered for this $175 external implementation, subject to proposal approval and the normal Upwork onboarding/contract requirements.

Problem: On v9.5.33-1, the Concierge composer can suggest “Export my last report to PDF” immediately after onboarding even though the account has no expenses or reports. The automated web check verified an empty account but displayed a different random suggestion; the exact reported prompt was not independently reproduced.

Bounded source finding (static only): In ComposerInput.tsx at pinned historical SHA a2011ae1473e25050a31c86a334998529f1f0ed6, ASK_CONCIERGE_PLACEHOLDER_KEYS includes exportPdf/exportCsv, and useState selects a key once at mount without checking whether an exportable report exists. The Concierge branch then translates that key. This supports a missing eligibility gate as a hypothesis for the reported mismatch, not a runtime-proven cause; whether a report is exportable rather than merely present needs verification.

Proposed scope after approval: verify the current source head and the report-eligibility contract; filter only action-dependent suggestion keys, retain safe generic fallbacks while report data is unknown, and avoid a stale selected key when eligibility changes. A discriminating regression would force the random PDF candidate for (a) no reports, (b) a qualifying report, and (c) delayed report data, plus check removal/no-placeholder flicker. No tests or app reproduction have been run by me. Estimated focused implementation plus tests: 1–2 working days after approval and a usable test setup.

One scope question: should the no-report Concierge state exclude every report-dependent suggestion, or only export-PDF/CSV until each prompt's prerequisites are defined?

I use AI assistance for source analysis and drafting; any code and test results would be reviewed and reported separately. I will not start a paid implementation or claim an assignment before approval.

xmejl avatar Nov 07 '26 17:11 xmejl

Proposal

Please re-state the problem that we are trying to solve in this issue.

When a new user completes onboarding (with zero expenses and zero expense reports) and opens the main Concierge Inbox DM, the message composer placeholder can display history-dependent prompts such as "Export my last report to PDF" (or "What drove my spend last quarter?", "Give me a CSV of my expenses over $50", etc.), suggesting actions on reports or expenses that do not exist yet.

What is the root cause of that problem?

In src/pages/inbox/report/ReportActionCompose/ComposerInput.tsx:36-52, ASK_CONCIERGE_PLACEHOLDER_KEYS defines 15 static translation keys:

const ASK_CONCIERGE_PLACEHOLDER_KEYS = [
    'common.concierge.composerPlaceholders.spendLastMonth',
    'common.concierge.composerPlaceholders.topExpenses',
    'common.concierge.composerPlaceholders.spendDrivers',
    'common.concierge.composerPlaceholders.travelSpendChange',
    'common.concierge.composerPlaceholders.topSpender',
    'common.concierge.composerPlaceholders.missingCategory',
    'common.concierge.composerPlaceholders.awaitingApproval',
    'common.concierge.composerPlaceholders.notReimbursed',
    'common.concierge.composerPlaceholders.unsubmitted',
    'common.concierge.composerPlaceholders.leftToPay',
    'common.concierge.composerPlaceholders.createExpense',
    'common.concierge.composerPlaceholders.combineExpenses',
    'common.concierge.composerPlaceholders.exportPdf',
    'common.concierge.composerPlaceholders.exportCsv',
    'reportActionCompose.askConciergeForHelp',
] as const;

At line 90, ComposerInput unconditionally selects one key on initial mount:

const [askConciergePlaceholderKey] = useState(() => ASK_CONCIERGE_PLACEHOLDER_KEYS[Math.floor(Math.random() * ASK_CONCIERGE_PLACEHOLDER_KEYS.length)]);

And at lines 101-102, when isConciergeInboxDM is true, it renders translate(askConciergePlaceholderKey).

13 of the 15 keys in ASK_CONCIERGE_PLACEHOLDER_KEYS presuppose that the user already has existing expenses or expense reports (exportPdf, exportCsv, spendLastMonth, topExpenses, spendDrivers, travelSpendChange, topSpender, missingCategory, awaitingApproval, notReimbursed, unsubmitted, leftToPay, combineExpenses), whereas only 2 keys ('common.concierge.composerPlaceholders.createExpense' and 'reportActionCompose.askConciergeForHelp') are valid for a brand-new user with no expenses or expense reports. Because ComposerInput never checks whether the user has any money-request reports or transactions before choosing the placeholder (and locks the choice on first mount via useState before Onyx data may have finished hydrating), a new user with no expenses/reports is shown prompts for actions they cannot perform.

What changes do you think we should make in order to solve the problem?

  1. Split Concierge placeholder keys into always-valid vs. expense/report-dependent sets in src/pages/inbox/report/ReportActionCompose/ComposerInput.tsx:
    • Define BASE_CONCIERGE_PLACEHOLDER_KEYS containing prompts that any user (including a brand-new user with 0 expenses/reports) can act on:
      const BASE_CONCIERGE_PLACEHOLDER_KEYS = [
          'common.concierge.composerPlaceholders.createExpense',
          'reportActionCompose.askConciergeForHelp',
      ] as const;
      
    • Define EXPENSE_DEPENDENT_CONCIERGE_PLACEHOLDER_KEYS containing the remaining 13 prompts that require existing expenses/reports (spendLastMonth, topExpenses, spendDrivers, travelSpendChange, topSpender, missingCategory, awaitingApproval, notReimbursed, unsubmitted, leftToPay, combineExpenses, exportPdf, exportCsv), and keep ASK_CONCIERGE_PLACEHOLDER_KEYS = [...BASE_CONCIERGE_PLACEHOLDER_KEYS, ...EXPENSE_DEPENDENT_CONCIERGE_PLACEHOLDER_KEYS] as const.
  2. Gate expense/report-dependent placeholders on whether the user has any money-request report or transaction (only when isConciergeInboxDM is true):
    • Add a lightweight boolean selector in src/pages/inbox/report/ReportActionCompose/ComposerInput.tsx (or a dedicated hook useHasAnyExpenseOrReport(enabled: boolean)) that subscribes to ONYXKEYS.COLLECTION.REPORT (checking Object.values(reports ?? {}).some((r) => isMoneyRequestReport(r))) and ONYXKEYS.COLLECTION.TRANSACTION (checking Object.values(transactions ?? {}).some(Boolean)) when isConciergeInboxDM is true (passing canBeMissing: true and skipping evaluation on non-Concierge chats so regular report composers incur zero overhead).
    • Store a stable random float const [randomSeed] = useState(() => Math.random()) once per mount so the placeholder never flickers across re-renders, and select from eligiblePlaceholderKeys = hasExpenseOrReport ? ASK_CONCIERGE_PLACEHOLDER_KEYS : BASE_CONCIERGE_PLACEHOLDER_KEYS:
      const eligibleConciergePlaceholderKeys = hasExpenseOrReport ? ASK_CONCIERGE_PLACEHOLDER_KEYS : BASE_CONCIERGE_PLACEHOLDER_KEYS;
      const askConciergePlaceholderKey = eligibleConciergePlaceholderKeys[Math.floor(randomSeed * eligibleConciergePlaceholderKeys.length)];
      
    • This guarantees:
      • A brand-new user with no expenses or expense reports only sees actionable prompts ("Create an expense for a $30 lunch" or "Ask Concierge for help") and never sees "Export my last report to PDF" or spend-history prompts.
      • If Onyx finishes loading reports/transactions asynchronously after mount, eligibleConciergePlaceholderKeys updates cleanly without flickering on subsequent Onyx writes because randomSeed is fixed per mount.
  3. Add unit tests in tests/unit/ComposerInputConciergePlaceholderTest.tsx:
    • Test that when ONYXKEYS.COLLECTION.REPORT and ONYXKEYS.COLLECTION.TRANSACTION are empty (new user), the Concierge DM placeholder is never exportPdf (even when Math.random is mocked to target the exportPdf index) and always resolves to BASE_CONCIERGE_PLACEHOLDER_KEYS.
    • Test that once a money-request report exists in Onyx, exportPdf and the full ASK_CONCIERGE_PLACEHOLDER_KEYS pool become eligible.

What alternative solutions did you explore? (Optional)

  • Filtering only exportPdf and exportCsv while leaving the other 11 spend/report prompts: As seen in the automated reproduction screenshot on this issue (where a brand-new user saw "What drove my spend last quarter?"), leaving spendDrivers, awaitingApproval, notReimbursed, or combineExpenses in the pool for a user with zero reports/expenses still violates the expected result ("Suggested input is something the user can actually do"). Splitting into BASE_CONCIERGE_PLACEHOLDER_KEYS vs. EXPENSE_DEPENDENT_CONCIERGE_PLACEHOLDER_KEYS solves the entire class of new-user placeholder mismatches cleanly.
  • Checking useOnyx(ONYXKEYS.COLLECTION.REPORT) unconditionally in every ComposerInput instance: ComposerInput renders on every chat/report screen. Gating the selector on isConciergeInboxDM ensures non-Concierge chats do not run collection scans.

zaidrain06 avatar Nov 07 '26 17:11 zaidrain06

Proposal

What is the root cause of that problem?

In src/pages/inbox/report/ReportActionCompose/ComposerInput.tsx (lines 36–52, 90), askConciergePlaceholderKey is initialized unconditionally on initial render from ASK_CONCIERGE_PLACEHOLDER_KEYS:

const [askConciergePlaceholderKey] = useState(() => ASK_CONCIERGE_PLACEHOLDER_KEYS[Math.floor(Math.random() * ASK_CONCIERGE_PLACEHOLDER_KEYS.length)]);

This array combines general prompts with action-dependent prompts that strictly require existing expense reports (e.g. exportPdf, awaitingApproval) or transaction history (e.g. spendLastMonth, topExpenses, spendDrivers, travelSpendChange, topSpender, missingCategory, notReimbursed, unsubmitted, leftToPay, combineExpenses, exportCsv).

Because candidate placeholders are selected statically on first mount without verifying whether the user has any expense reports or transactions in Onyx (and before Onyx may have hydrated), a brand-new user with zero expenses or reports is shown prompts for actions they cannot perform.

What changes do you think we should make in order to solve the problem?

  1. Partition ASK_CONCIERGE_PLACEHOLDER_KEYS by prerequisite in src/pages/inbox/report/ReportActionCompose/ComposerInput.tsx:

    • Define BASE_CONCIERGE_PLACEHOLDER_KEYS for prompts that any user (including a brand-new user with 0 expenses and 0 reports) can always perform:
      const BASE_CONCIERGE_PLACEHOLDER_KEYS = [
          'common.concierge.composerPlaceholders.createExpense',
          'reportActionCompose.askConciergeForHelp',
      ] as const;
      
    • Define EXPENSE_DEPENDENT_CONCIERGE_PLACEHOLDER_KEYS for the remaining 13 prompts that require existing expenses/reports (spendLastMonth, topExpenses, spendDrivers, travelSpendChange, topSpender, missingCategory, awaitingApproval, notReimbursed, unsubmitted, leftToPay, combineExpenses, exportPdf, exportCsv).
    • Retain ASK_CONCIERGE_PLACEHOLDER_KEYS = [...BASE_CONCIERGE_PLACEHOLDER_KEYS, ...EXPENSE_DEPENDENT_CONCIERGE_PLACEHOLDER_KEYS] as const.
  2. Add lightweight, high-performance boolean selectors: Follow the proven pattern from src/pages/Search/EmptySearchView.tsx (lines 115–119) with delete-pending filtering:

    const hasExpenseReportsSelector = (reports: OnyxCollection<Report>) =>
        Object.values(reports ?? {}).some(
            (report) => (report?.type === CONST.REPORT.TYPE.EXPENSE || isMoneyRequestReport(report)) && report?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
        );
    
    const hasTransactionsSelector = (transactions: OnyxCollection<Transaction>) =>
        Object.values(transactions ?? {}).some(
            (transaction) => !!transaction && transaction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
        );
    
  3. Gate evaluation to zero-overhead for non-Concierge chats in ComposerInput.tsx: Curry the selectors with isConciergeInboxDM:

    const hasExpenseReportsSelectorCurried = useCallback(
        (reports: OnyxCollection<Report>) => (isConciergeInboxDM ? hasExpenseReportsSelector(reports) : false),
        [isConciergeInboxDM],
    );
    
    const hasTransactionsSelectorCurried = useCallback(
        (transactions: OnyxCollection<Transaction>) => (isConciergeInboxDM ? hasTransactionsSelector(transactions) : false),
        [isConciergeInboxDM],
    );
    
    const [hasExpenseReports = false] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {selector: hasExpenseReportsSelectorCurried});
    const [hasTransactions = false] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {selector: hasTransactionsSelectorCurried});
    const hasExpenseOrReport = hasExpenseReports || hasTransactions;
    

    When !isConciergeInboxDM, the selector returns false immediately in O(1) time without iterating collections. For Concierge chats, returning primitive booleans prevents any re-renders unless the boolean state actually transitions.

  4. Derive the eligible placeholder without flicker: Store a stable random seed float on mount and derive the key with useMemo:

    const [randomSeed] = useState(() => Math.random());
    
    const askConciergePlaceholderKey = useMemo(() => {
        const eligibleKeys = hasExpenseOrReport ? ASK_CONCIERGE_PLACEHOLDER_KEYS : BASE_CONCIERGE_PLACEHOLDER_KEYS;
        return eligibleKeys[Math.floor(randomSeed * eligibleKeys.length)];
    }, [hasExpenseOrReport, randomSeed]);
    
    • For a brand-new user with zero expenses/reports, only actionable prompts ("Create an expense for a $30 lunch" or "Ask Concierge for help") are selected.
    • "Export my last report to PDF" and spend analysis prompts are never shown when no reports or expenses exist.
    • When Onyx hydrates or when an expense is created, hasExpenseOrReport updates seamlessly and randomSeed prevents re-render flickering.

What alternative solutions did you explore? (Optional)- Only filtering exportPdf / exportCsv: Rejected because leaving spendDrivers, awaitingApproval, combineExpenses, etc. in the pool still presents prompts to a new user that they cannot perform, violating the expected result.

  • Unconditional useOnyx collection scan: Rejected because running collection scans across all chat composers impacts performance. Currying with isConciergeInboxDM guarantees O(1) bypass for all regular chats.

Tests

  1. Log in with a fresh new account (0 expenses, 0 reports).
  2. Open Concierge DM in Inbox.
  3. Verify the composer placeholder displays an actionable prompt (e.g. "Create an expense for a $30 lunch" or "Ask Concierge for help…").
  4. Verify "Export my last report to PDF" and other report/spend-dependent prompts are never shown.
  5. Create an expense or report.
  6. Verify that report/spend-dependent prompts become eligible in Concierge DM.
  7. Open a standard DM or workspace chat and verify composer placeholder functions normally with no performance degradation.
  • [x] Verify that no errors appear in the JS console

Automated Unit Tests

Add unit tests in tests/unit/ComposerInputConciergePlaceholderTest.tsx:

  • Verify that with empty Onyx collections, the selected Concierge placeholder is strictly from BASE_CONCIERGE_PLACEHOLDER_KEYS even when Math.random is mocked to target indices of exportPdf or spendDrivers.
  • Verify that once a report or transaction is added to Onyx, exportPdf and the full ASK_CONCIERGE_PLACEHOLDER_KEYS pool become eligible.

Contributor details

Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374

kevinjosh10 avatar Nov 07 '26 17:11 kevinjosh10

Proposal

Please re-state the problem that we are trying to solve in this issue.

When a brand-new user completes onboarding (zero expenses, zero expense reports) and opens the Concierge Inbox DM, the composer placeholder can show history-dependent prompts such as "Export my last report to PDF", suggesting actions on reports or expenses that do not exist yet.

What is the root cause of that problem?

In src/pages/inbox/report/ReportActionCompose/ComposerInput.tsx, ASK_CONCIERGE_PLACEHOLDER_KEYS (lines 36-52) mixes prompts that need different underlying data, and line 90 picks one at random with useState on first mount, with no check on the user's data at all. The isConciergeInboxDM branch then renders the pick unconditionally. So a new user can be shown exportPdf (or exportCsv, awaitingApproval, spendLastMonth, etc.) when there is nothing to export or analyse. MelvinBot's web test confirms the prompt is selectable with no report-availability check.

What changes do you think we should make in order to solve the problem?

Filter the candidate keys by what the user actually has, in two tiers, because one gate is not enough:

  • Spend-analysis prompts (spendLastMonth, topExpenses, spendDrivers, travelSpendChange, topSpender, missingCategory) need transaction history, not just a report. Gating only on "has a report" would still show "What drove my spend last quarter?" to a user with one empty report and zero transactions.
  • Report-action prompts (exportPdf, exportCsv, awaitingApproval, notReimbursed, unsubmitted, leftToPay, combineExpenses) need at least one money-request report.
  • Compute both flags from Onyx: ONYXKEYS.COLLECTION.REPORT filtered with isMoneyRequestReport (already imported in this file) for reports, and ONYXKEYS.COLLECTION.TRANSACTION for transactions.
  • Because useState freezes the pick at first mount and Onyx may not be hydrated yet, recompute the pick with useMemo keyed on the two eligibility flags, so a key picked before data loads is replaced once eligibility is known. While data is loading, or when neither tier is eligible, fall back to the always-safe keys (createExpense, askConciergeForHelp), so the list is never empty.

What will you verify?

  • Jest test forcing the random pick to each tier for: (a) no reports and no transactions, (b) reports present but zero transactions, (c) transactions present, (d) delayed Onyx hydration (pick made before data loads is corrected once data arrives).
  • Manual check on a fresh account: open the Concierge DM repeatedly and confirm no report- or transaction-dependent prompt ever appears, and that a generic prompt is shown instead.

khizzcr7 avatar Nov 07 '26 18:11 khizzcr7

Proposal

Please re-state the problem that we are trying to solve in this issue.

When a brand-new user (with no expenses or expense reports) opens the Concierge chat right after onboarding, the composer input placeholder can display prompts such as "Export my last report to PDF" (or other report/expense-dependent prompts like "Export my last report to CSV", "Show reports awaiting my approval", etc.) that cannot work because the user has no reports or expenses yet.

What is the root cause of that problem?

In src/pages/inbox/report/ReportActionCompose/ComposerInput.tsx (lines 36-52), ASK_CONCIERGE_PLACEHOLDER_KEYS is a single flat array of 15 translation keys:

const ASK_CONCIERGE_PLACEHOLDER_KEYS = [
    'common.concierge.composerPlaceholders.spendLastMonth',
    'common.concierge.composerPlaceholders.topExpenses',
    'common.concierge.composerPlaceholders.spendDrivers',
    'common.concierge.composerPlaceholders.travelSpendChange',
    'common.concierge.composerPlaceholders.topSpender',
    'common.concierge.composerPlaceholders.missingCategory',
    'common.concierge.composerPlaceholders.awaitingApproval',
    'common.concierge.composerPlaceholders.notReimbursed',
    'common.concierge.composerPlaceholders.unsubmitted',
    'common.concierge.composerPlaceholders.leftToPay',
    'common.concierge.composerPlaceholders.createExpense',
    'common.concierge.composerPlaceholders.combineExpenses',
    'common.concierge.composerPlaceholders.exportPdf',
    'common.concierge.composerPlaceholders.exportCsv',
    'reportActionCompose.askConciergeForHelp',
] as const satisfies readonly TranslationPaths[];

And at line 90 of src/pages/inbox/report/ReportActionCompose/ComposerInput.tsx:

const [askConciergePlaceholderKey] = useState(() => ASK_CONCIERGE_PLACEHOLDER_KEYS[Math.floor(Math.random() * ASK_CONCIERGE_PLACEHOLDER_KEYS.length)]);

There are two problems with this implementation:

  1. Unconditional pool: Only 2 of the 15 keys ('common.concierge.composerPlaceholders.createExpense' and 'reportActionCompose.askConciergeForHelp') are applicable to a user with zero expenses and zero expense reports. The remaining 13 keys require either existing expense/money-request reports (awaitingApproval, notReimbursed, unsubmitted, leftToPay, combineExpenses, exportPdf, exportCsv) or existing expense transactions (spendLastMonth, topExpenses, spendDrivers, travelSpendChange, topSpender, missingCategory).
  2. One-shot useState initializer: Selecting the key inside useState(() => ...) runs only once when ComposerInput first mounts and cannot adapt as Onyx finishes hydrating ONYXKEYS.COLLECTION.REPORT / ONYXKEYS.COLLECTION.TRANSACTION or when the user creates/deletes their first report or expense.

What changes do you think we should make in order to solve the problem?

  1. Partition ASK_CONCIERGE_PLACEHOLDER_KEYS in src/pages/inbox/report/ReportActionCompose/ComposerInput.tsx by data requirement:
    • BASE_CONCIERGE_PLACEHOLDER_KEYS: always eligible (createExpense, askConciergeForHelp).
    • REPORT_CONCIERGE_PLACEHOLDER_KEYS: eligible only when the user has at least one non-deleted money-request report (awaitingApproval, notReimbursed, unsubmitted, leftToPay, combineExpenses, exportPdf, exportCsv).
    • TRANSACTION_CONCIERGE_PLACEHOLDER_KEYS: eligible only when the user has at least one non-deleted transaction (spendLastMonth, topExpenses, spendDrivers, travelSpendChange, topSpender, missingCategory).
const BASE_CONCIERGE_PLACEHOLDER_KEYS = [
    'common.concierge.composerPlaceholders.createExpense',
    'reportActionCompose.askConciergeForHelp',
] as const satisfies readonly TranslationPaths[];

const REPORT_CONCIERGE_PLACEHOLDER_KEYS = [
    'common.concierge.composerPlaceholders.awaitingApproval',
    'common.concierge.composerPlaceholders.notReimbursed',
    'common.concierge.composerPlaceholders.unsubmitted',
    'common.concierge.composerPlaceholders.leftToPay',
    'common.concierge.composerPlaceholders.combineExpenses',
    'common.concierge.composerPlaceholders.exportPdf',
    'common.concierge.composerPlaceholders.exportCsv',
] as const satisfies readonly TranslationPaths[];

const TRANSACTION_CONCIERGE_PLACEHOLDER_KEYS = [
    'common.concierge.composerPlaceholders.spendLastMonth',
    'common.concierge.composerPlaceholders.topExpenses',
    'common.concierge.composerPlaceholders.spendDrivers',
    'common.concierge.composerPlaceholders.travelSpendChange',
    'common.concierge.composerPlaceholders.topSpender',
    'common.concierge.composerPlaceholders.missingCategory',
] as const satisfies readonly TranslationPaths[];
  1. Use O(1)-gated boolean useOnyx selectors and a stable per-mount random seed in ComposerInput: In src/pages/inbox/report/ReportActionCompose/ComposerInput.tsx, compute isConciergeInboxDM first, and short-circuit the collection selectors when !isConciergeInboxDM so non-Concierge chats do zero work over ONYXKEYS.COLLECTION.REPORT and ONYXKEYS.COLLECTION.TRANSACTION. Store a stable random float const [placeholderRandomSeed] = useState(() => Math.random()); on mount and derive askConciergePlaceholderKey from the eligible pool:
const isConciergeInboxDM = isTopLevelInline && isChatThread(report) && isConciergeChatReport(report);

const hasMoneyRequestReportSelector = useCallback(
    (reports: OnyxCollection<Report>) => {
        if (!isConciergeInboxDM || !reports) {
            return false;
        }
        return Object.values(reports).some(
            (candidateReport) =>
                isMoneyRequestReport(candidateReport) &&
                candidateReport?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
        );
    },
    [isConciergeInboxDM],
);

const hasTransactionSelector = useCallback(
    (transactions: OnyxCollection<Transaction>) => {
        if (!isConciergeInboxDM || !transactions) {
            return false;
        }
        return Object.values(transactions).some(
            (transaction) =>
                !!transaction &&
                transaction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
        );
    },
    [isConciergeInboxDM],
);

const [hasMoneyRequestReports = false] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {
    selector: hasMoneyRequestReportSelector,
});
const [hasTransactions = false] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {
    selector: hasTransactionSelector,
});

const [placeholderRandomSeed] = useState(() => Math.random());

const eligibleConciergePlaceholderKeys = [
    ...BASE_CONCIERGE_PLACEHOLDER_KEYS,
    ...(hasMoneyRequestReports ? REPORT_CONCIERGE_PLACEHOLDER_KEYS : []),
    ...(hasTransactions ? TRANSACTION_CONCIERGE_PLACEHOLDER_KEYS : []),
];
const askConciergePlaceholderKey =
    eligibleConciergePlaceholderKeys[Math.floor(placeholderRandomSeed * eligibleConciergePlaceholderKeys.length)];

Because both useOnyx hooks return primitive booleans (hasMoneyRequestReports and hasTransactions), ComposerInput will not re-render on ordinary report or transaction mutations—only when the user transitions between having 0 and >= 1 money-request reports or transactions (or when Onyx finishes initial hydration).

What alternative solutions did you explore? (Optional)

  • Checking ONYXKEYS.HAS_LOADED_APP or tryNewDot onboarding flags: Onboarding flags do not guarantee that a user has created an expense or a report (and conversely, an existing user may have deleted all reports). Checking actual report/transaction existence via boolean selectors directly reflects whether report/expense prompts are actionable.
  • Combining all 13 non-base prompts behind a single hasTransactions || hasMoneyRequestReports check: A user who has only a tracked self-DM transaction (with no expense report) still cannot "Export my last report to PDF". Separating REPORT_CONCIERGE_PLACEHOLDER_KEYS (hasMoneyRequestReports) from TRANSACTION_CONCIERGE_PLACEHOLDER_KEYS (hasTransactions) ensures report-export prompts only appear when a report actually exists.

e5ash avatar Nov 07 '26 18:11 e5ash

Proposal

Please re-state the problem that we are trying to solve in this issue.

When a brand-new user completes onboarding (with zero expenses and zero expense reports) and opens the Concierge chat, the message composer input placeholder randomly displays action prompts that operate on non-existent data (such as "Export my last report to PDF", "Export my last report to CSV", or historical spend queries like "What drove my spend last quarter?"), suggesting actions the user cannot perform.

What is the root cause of that problem?

In src/pages/inbox/report/ReportActionCompose/ComposerInput.tsx:

  1. Lines 36-52 define ASK_CONCIERGE_PLACEHOLDER_KEYS, combining general onboarding prompts (e.g. createExpense, askConciergeForHelp) with history-dependent prompts that strictly require pre-existing reports or expenses (exportPdf, exportCsv, spendLastMonth, topExpenses, spendDrivers, awaitingApproval, unsubmitted, leftToPay, combineExpenses).
  2. At line 90:
const [askConciergePlaceholderKey] = useState(() => ASK_CONCIERGE_PLACEHOLDER_KEYS[Math.floor(Math.random() * ASK_CONCIERGE_PLACEHOLDER_KEYS.length)]);

ComposerInput uniformly picks a random key from the static array on initial render without checking if the user actually has any expense reports or transactions in Onyx.

What changes do you think we should make in order to solve the problem?

  1. In src/pages/inbox/report/ReportActionCompose/ComposerInput.tsx, partition the placeholders into general onboarding prompts and history-dependent prompts:
const ONBOARDING_CONCIERGE_PLACEHOLDER_KEYS = [
    'common.concierge.composerPlaceholders.createExpense',
    'reportActionCompose.askConciergeForHelp',
] as const;
  1. Check whether the user has existing expense reports (using Onyx reports collection or checking if any non-empty transaction exists). If the user has no expense reports, draw randomly from ONBOARDING_CONCIERGE_PLACEHOLDER_KEYS. If expense reports exist, draw from the full ASK_CONCIERGE_PLACEHOLDER_KEYS.

What alternative solutions did you explore? (Optional)

Filtering the keys dynamically by verifying report count inside a custom hook useConciergeComposerPlaceholder(reportID). However, keeping the partition in ComposerInput is cleaner and minimizes re-renders.

Contributor Details

Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0179cdc82689f205c7

TassioSales avatar Nov 07 '26 21:11 TassioSales

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 07 '26 21:11 melvin-bot[bot]

Proposal

Please re-state the problem that we are trying to solve in this issue.

When a brand-new user who has no expenses or money request reports opens the Concierge chat (or the "Ask Concierge" panel), the composer input displays prompts such as "Export my last report to PDF" that presuppose existing expenses or reports. If the user submits that prompt, Concierge responds that the user has no reports to export.

What is the root cause of that problem?

In src/pages/inbox/report/ReportActionCompose/ComposerInput.tsx (introduced in PR #100552), ASK_CONCIERGE_PLACEHOLDER_KEYS is a single static array of 15 translation keys:

const ASK_CONCIERGE_PLACEHOLDER_KEYS = [
    'common.concierge.composerPlaceholders.spendLastMonth',
    'common.concierge.composerPlaceholders.topExpenses',
    'common.concierge.composerPlaceholders.spendDrivers',
    'common.concierge.composerPlaceholders.travelSpendChange',
    'common.concierge.composerPlaceholders.topSpender',
    'common.concierge.composerPlaceholders.missingCategory',
    'common.concierge.composerPlaceholders.awaitingApproval',
    'common.concierge.composerPlaceholders.notReimbursed',
    'common.concierge.composerPlaceholders.unsubmitted',
    'common.concierge.composerPlaceholders.leftToPay',
    'common.concierge.composerPlaceholders.createExpense',
    'common.concierge.composerPlaceholders.combineExpenses',
    'common.concierge.composerPlaceholders.exportPdf',
    'common.concierge.composerPlaceholders.exportCsv',
    'reportActionCompose.askConciergeForHelp',
] as const;

And at lines 89–90 and lines 102–103, ComposerInput picks uniformly at random from all 15 keys without checking whether the user actually has any expenses or non-empty money request reports in Onyx:

const isConciergeInboxDM = useIsConciergeInboxDM(reportID);
const [askConciergePlaceholderKey] = useState(() => ASK_CONCIERGE_PLACEHOLDER_KEYS[Math.floor(Math.random() * ASK_CONCIERGE_PLACEHOLDER_KEYS.length)]);
...
} else if (isConciergeInboxDM) {
    inputPlaceholder = translate(askConciergePlaceholderKey);
}

Specifically:

  1. Only 2 of the 15 keys ('common.concierge.composerPlaceholders.createExpense' and 'reportActionCompose.askConciergeForHelp') are actionable for a new user with no expenses or reports.
  2. Nine keys (spendLastMonth, topExpenses, spendDrivers, travelSpendChange, topSpender, missingCategory, unsubmitted, combineExpenses, exportCsv) require the user to have at least one existing transaction in ONYXKEYS.COLLECTION.TRANSACTION (including self-DM tracked expenses that may not belong to a money request report yet).
  3. Four keys (awaitingApproval, notReimbursed, leftToPay, exportPdf) require the user to have at least one non-empty money request report (isMoneyRequestReport(report) && ((report.transactionCount ?? 0) > 0 || (report.total ?? 0) !== 0) — note that an empty draft report with transactionCount === 0 cannot be exported to PDF, as enforced in useExportActions.ts:126).
  4. In addition, because useState initializes askConciergePlaceholderKey once on initial mount, if Onyx collections finish hydrating after mount or the available pool changes, a mount-only useState initializer cannot adapt to the loaded state.

What changes do you think we should make in order to solve the problem?

In src/pages/inbox/report/ReportActionCompose/ComposerInput.tsx:

  1. Split the Concierge composer placeholder keys into:
    • DEFAULT_ASK_CONCIERGE_PLACEHOLDER_KEYS: always-valid prompts (createExpense, askConciergeForHelp).
    • EXPENSE_ASK_CONCIERGE_PLACEHOLDER_KEYS: prompts that require at least one non-deleted transaction (spendLastMonth, topExpenses, spendDrivers, travelSpendChange, topSpender, missingCategory, unsubmitted, combineExpenses, exportCsv).
    • REPORT_ASK_CONCIERGE_PLACEHOLDER_KEYS: prompts that require at least one non-empty money request report (awaitingApproval, notReimbursed, leftToPay, exportPdf).
  2. When isConciergeInboxDM is true, subscribe to ONYXKEYS.COLLECTION.TRANSACTION and ONYXKEYS.COLLECTION.REPORT with lightweight boolean selectors (hasUserTransactionsSelector and hasNonEmptyMoneyRequestReportsSelector, gated via {canBeMissing: true} and only active for the Concierge DM).
  3. Compute the eligible placeholder pool and memoize a stable random pick from the eligible keys (re-picking only if the currently selected key is not in the eligible pool or when the eligible pool expands).

What alternative solutions did you explore? (Optional)

  • Checking isMoneyRequestReport(report) without checking transactionCount / total: An empty draft report (transactionCount === 0) cannot be exported to PDF (useExportActions.ts:126), so requiring isMoneyRequestReport(item) && ((item.transactionCount ?? 0) > 0 || (item.total ?? 0) !== 0) ensures "Export my last report to PDF" is only shown when a report with actual expenses exists.
  • Checking only ONYXKEYS.COLLECTION.REPORT for all 13 expense/report prompts: A user who tracks expenses in their self-DM has transactions in ONYXKEYS.COLLECTION.TRANSACTION without a money request report (unsubmitted, combineExpenses, exportCsv, and spend-insight prompts are valid, whereas exportPdf is not). Separating expense-dependent keys from report-dependent keys handles both cases accurately.

cocvn157 avatar Nov 08 '26 02:11 cocvn157

📣 @cocvn157! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Nov 08 '26 02:11 melvin-bot[bot]

@MelvinBot implement your proposal

mkhutornyi avatar Nov 08 '26 16:11 mkhutornyi

🤖 Web test steps verification results: ✅ pass

Verified on dev NewDot web: empty-account Concierge displayed the allowed lunch prompt, and self-chat retained its normal composer. Nothing was sent or created.

Personal chat retaining the normal composer placeholder
Step Status
Account has no expenses or reportsExpenses showed “No expenses yet”; Reports showed “No reports yet.”
✅
Main Concierge composer shows an eligible promptDisplayed “Create an expense for a $30 lunch” and remained stable after expanding chat history.
Empty-account Concierge showing the allowed lunch placeholder
✅
Ordinary chat composer remains unchangedSelf-chat displayed “Write something...” as expected.
Personal chat retaining the normal composer placeholder
✅

Implemented in draft PR: Fix Concierge placeholders for accounts without expenses, assigned to mkhutornyi, with PullerBear review requested.

  • Passed: 38,232 tests, including 25 new regression tests; lint, typecheck, spelling, and Storybook smoke checks.
  • Remaining verification: formatting check unavailable; changed-file compiler check could not resolve its base reference, though the explicit-file check succeeded. Browser console errors were not collected.
  • Human Tests/QA sections remain for completion before marking ready for review.

view run

MelvinBot avatar Nov 08 '26 17:11 MelvinBot

I went with Melvin but I had to address many things during PR review. 🎀 👀 🎀 C+ reviewed

Edit: There are still many bugs to be addressed. In the end, I had to create PR myself to speed up things. Melvin is very slow and could not catch regressions.

mkhutornyi avatar Nov 09 '26 03:11 mkhutornyi

Triggered auto assignment to @marcochavezf, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

melvin-bot[bot] avatar Nov 09 '26 03:11 melvin-bot[bot]

Claude posting on behalf of Matt:

@MelvinBot implement your proposal. Use the closed PR https://github.com/Expensify/App/pull/106335 as a reference. It holds the changes from the earlier review.

mallenexpensify avatar Nov 23 '26 21:11 mallenexpensify

⏱️ Ran out of time before I could finish. This usually means the task was too complex or I got stuck exploring. Please try again with a more specific request or post in #melvinbot-ai.

Run details

MelvinBot avatar Nov 23 '26 22:11 MelvinBot

Matt's AI agent:

@ahmedGaber93 you're now the C+ on this issue. The previous C+ is no longer in the Contributor program.

The previous C+ accepted Melvin's proposal, then wrote PR 106335, which is now closed. On the last request, Melvin ran out of time.

Next step: post @MelvinBot open a new PR with the changes from closed PR 106335. Do not change anything else. Then review that PR. @marcochavezf is the engineer.

mallenexpensify avatar Dec 02 '26 00:12 mallenexpensify