Skip to content

Make Concierge aware of the active report and/or selected transactions#86149

Open
youssef-lr wants to merge 31 commits intomainfrom
youssef_concierge_anywhere_report_context
Open

Make Concierge aware of the active report and/or selected transactions#86149
youssef-lr wants to merge 31 commits intomainfrom
youssef_concierge_anywhere_report_context

Conversation

@youssef-lr
Copy link
Copy Markdown
Contributor

@youssef-lr youssef-lr commented Mar 23, 2026

Explanation of Change

This PR allows Concierge Anywhere to be aware of any currently open expense report or transaction thread, as well as selected transactions inside an expense report view, and selected transactions/reports in the Reports page.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/613557
$ https://github.com/Expensify/Expensify/issues/614472

Tests

  • Verify that no errors appear in the JS console
  1. Open an expense report with multiple transactions
  2. Open Concierge Anywhere from the side pane
  3. Ask Concierge "Update all transactions in this report to have category Car"
  4. Verify the update succeeds
  5. Select one transaction from the report and ask Concierge to update the category
  6. Verify the update succeeds
  7. Create a single expense report
  8. Open Concierge Anywhere and ask it "Update this transaction's category.."
  9. Verify the update succeeds
  10. Go to the Reports => Expenses page
  11. Select a few transactions and ask Concierge to update their category
  12. Verify the update succeeds

Offline tests

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
  • I added steps for local testing in the Tests section
  • I added steps for the expected offline behavior in the Offline steps section
  • I added steps for Staging and/or Production testing in the QA steps section
  • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
  • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
  • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
  • I verified that comments were added to code that is not self explanatory
  • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
  • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
  • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
  • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
  • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
  • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
  • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
  • A similar style doesn't already exist
  • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
  • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
  • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
  • I verified that all the inputs inside a form are aligned with each other.
  • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@youssef-lr youssef-lr changed the title Store the currently opened report in Onyx Make Concierge aware of the currently opened report Mar 23, 2026
@youssef-lr youssef-lr changed the title Make Concierge aware of the currently opened report Make Concierge aware of the active report Mar 23, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 23, 2026

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
...ox/report/ReportActionCompose/useComposerSubmit.ts 22.72% <ø> (ø)
.../report/ReportActionCompose/useSidePanelContext.ts 100.00% <100.00%> (ø)
src/libs/actions/Report/index.ts 68.94% <88.88%> (-0.01%) ⬇️
src/hooks/useCurrentReportID.tsx 71.05% <54.54%> (-25.11%) ⬇️
... and 9 files with indirect coverage changes

@youssef-lr youssef-lr changed the title Make Concierge aware of the active report Make Concierge aware of the active report and/or selected transactions Apr 3, 2026
@youssef-lr youssef-lr changed the title Make Concierge aware of the active report and/or selected transactions [HOLD Web-E #51676] Make Concierge aware of the active report and/or selected transactions Apr 7, 2026
@youssef-lr youssef-lr changed the title [HOLD Web-E #51676] Make Concierge aware of the active report and/or selected transactions Make Concierge aware of the active report and/or selected transactions Apr 13, 2026
@youssef-lr youssef-lr marked this pull request as ready for review April 14, 2026 22:39
@youssef-lr youssef-lr requested review from a team as code owners April 14, 2026 22:39
@melvin-bot melvin-bot Bot requested a review from abzokhattab April 14, 2026 22:39
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented Apr 14, 2026

@abzokhattab Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot Bot removed the request for review from a team April 14, 2026 22:39
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5bd7620b44

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx Outdated
Comment thread src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx Outdated
@youssef-lr
Copy link
Copy Markdown
Contributor Author

I've address AI comments @abzokhattab

@abzokhattab
Copy link
Copy Markdown
Contributor

@MelvinBot Review the PR

@abzokhattab
Copy link
Copy Markdown
Contributor

@codex review

@abzokhattab
Copy link
Copy Markdown
Contributor

@youssef-lr great lets also add test cases for the hooks

@MelvinBot
Copy link
Copy Markdown
Contributor

PR Review

Overall this is a clean, well-scoped change. A few items to address:

Issues

  1. Naming mismatch (useCurrentReportID.tsx): The state is currentRHPReportID but the setter is setCurrentModalReportID. Pick one convention — suggest setCurrentRHPReportID to match the public name.

  2. sidePanelContext in submitForm dep array (ReportActionCompose.tsx:517): sidePanelContext is an object returned from useMemo, but its deps include selectedTransactions (a new object ref on every search state change) and selectedReports (an array). This means sidePanelContext will get a new ref frequently, which recreates the submitForm callback and triggers re-renders of anything consuming it. Consider either:

    • Stabilizing the useMemo inputs (e.g. deriving a primitive key from the selected items), or
    • Moving sidePanelContext out of the useCallback dep array and reading it via a ref instead, since it's only needed at call time, not for memoization.
  3. Low test coverage — Codecov flags useSidePanelContext.ts at 14.28%. The reviewer comment from abzokhattab already asks for hook tests — +1, especially for the branching logic (expense report type, RHP vs main report, selected transactions from map vs array).

Suggestions (non-blocking)

  1. getFocusedRouteReportID — consider adding a depth guard to the recursion to prevent unexpected deep traversal if navigation state is malformed. Not critical since React Navigation states are well-structured, but defensive.

  2. Comma-separated IDs (selectedTransactionIDs, selectedReportIDs) — joining IDs into a comma-delimited string works but makes the type less self-documenting. If the backend expects this format, document it in the SidePanelContext type. If not, consider sending arrays and letting JSON.stringify handle serialization (since the whole object is already stringified at Report/index.ts:810).

  3. currentSearchQueryJSON?.type dep (useSidePanelContext.ts) — only .type is listed in the useMemo deps, which is correct since only .type is used. But if currentSearchQueryJSON itself is a new ref each render while .type stays the same, this is fine. Just confirming the intent is right.

Looks good

  • The getFocusedRouteReportID recursion logic is clean and correctly traverses modal navigator stacks.
  • The guard conciergeReportID !== reportID || !isInSidePanel ensures context is only built for the right chat.
  • Extracting isConciergeChat to avoid duplicate isConciergeChatReport() calls in addActions is a nice cleanup.
  • The SidePanelContext type is appropriately minimal.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1fc9ec7998

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// This condition is reached when we are either in the global Reports => Reports page, or within a single expense report having multiple transactions.
// If we have selectedReportIDs, that means we're in the Reports page, otherwise we're in the expense report RHP.
if (currentSearchQueryJSON?.type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT) {
return selectedReportIDsForContext ? {selectedReportIDs: selectedReportIDsForContext} : {reportID: contextReportID, selectedTransactionIDs: selectedTransactionIDsForContext};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Ignore stale selectedReportIDs in expense-report context

When currentSearchQueryJSON?.type is EXPENSE_REPORT, this branch always prefers selectedReportIDsForContext over the active report/transaction selection. That assumption is unsafe because selectedReports can remain populated from a previous Search selection while selectedTransactionIDs is updated elsewhere (the array update path in SearchContext does not clear selectedReports). In that state, Concierge receives old report IDs instead of the currently selected transactions/report, so bulk actions can target the wrong scope.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

selectedReports can remain populated from a previous Search selection while selectedTransactionIDs is updated elsewhere

This does not happen.

Comment thread src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx Outdated
@youssef-lr
Copy link
Copy Markdown
Contributor Author

Comma-separated IDs (selectedTransactionIDs, selectedReportIDs) — joining IDs into a comma-delimited string works but makes the type less self-documenting. If the backend expects this format, document it in the SidePanelContext type. If not, consider sending arrays and letting JSON.stringify handle serialization (since the whole object is already stringified at Report/index.ts:810).

@MelvinBot create an issue and assign to me to handle this update in the backend, as the backend currently accepts IDs this way.

@MelvinBot
Copy link
Copy Markdown
Contributor

Created https://github.com/Expensify/Expensify/issues/625067 and assigned to youssef-lr to handle updating the backend to accept arrays for selectedTransactionIDs and selectedReportIDs.

@youssef-lr
Copy link
Copy Markdown
Contributor Author

bump @abzokhattab

@abzokhattab
Copy link
Copy Markdown
Contributor

i thought its still in progress since we need a backend change .. no?

@youssef-lr
Copy link
Copy Markdown
Contributor Author

Ah no, we can implement the change in a follow up PR, I think we shouldn't block on it.

@abzokhattab
Copy link
Copy Markdown
Contributor

I'm following the steps, but I'm running into an issue .. after I open the report, the Concierge help button doesn't show up. How am I supposed to open Concierge Anywhere in this case?

Screen.Recording.2026-04-19.at.02.00.13.mov

@youssef-lr
Copy link
Copy Markdown
Contributor Author

@abzokhattab open it before opening the RHP report

@youssef-lr
Copy link
Copy Markdown
Contributor Author

bump @abzokhattab

@abzokhattab
Copy link
Copy Markdown
Contributor

Missed your reply sorry .. will finalize the checklist today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants