Skip to content

fix: Join button appear and expand horizontal on the first invoice on the Spend tab - #100063

Merged
luacmartins merged 2 commits into
Expensify:mainfrom
nkdengineer:fix/98882
Sep 1, 2026
Merged

fix: Join button appear and expand horizontal on the first invoice on the Spend tab#100063
luacmartins merged 2 commits into
Expensify:mainfrom
nkdengineer:fix/98882

Conversation

@nkdengineer

Copy link
Copy Markdown
Contributor

Explanation of Change

fix: Join button appear and expand horizontal on the first invoice on the Spend tab

Fixed Issues

$ #98882
PROPOSAL: #98882 (comment)

Tests

Precondition:

  • Create a new workspace and enable invoice
  • Create at least one invoice expense
  1. Go Spend > Invoice
  2. Go offline
  3. Create a new invoice expense from FAB
  4. Click on the new invoice row
  5. Verify that the invoice report is opened instead of the transaction thread report
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

Same as test

  • 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
  • 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 followed proper code patterns (see Reviewing the code)
    • 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 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)
  • 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)
  • 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.
  • 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
Screen.Recording.2026-09-01.at.23.05.46.mov
Android: mWeb Chrome
Screen.Recording.2026-09-01.at.22.59.33.mov
iOS: Native
Screen.Recording.2026-09-01.at.23.03.46.mov
iOS: mWeb Safari
Screen.Recording.2026-09-01.at.22.53.34.mov
MacOS: Chrome / Safari
Screen.Recording.2026-09-01.at.22.51.37.mov

@nkdengineer
nkdengineer marked this pull request as ready for review September 1, 2026 16:39
@nkdengineer
nkdengineer requested review from a team as code owners September 1, 2026 16:39
@melvin-bot
melvin-bot Bot requested review from aimane-chnaif and trjExpensify and removed request for a team September 1, 2026 16:39
@melvin-bot

melvin-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

@aimane-chnaif 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]

@aimane-chnaif

aimane-chnaif commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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 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)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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 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.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
ios.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
web1.mov
web2.mov

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: f65a490afe

ℹ️ 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".

@melvin-bot
melvin-bot Bot requested a review from luacmartins September 1, 2026 17:22
@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Web test steps verification results: ✅ pass

Invoices created online and offline both list correctly under Spend > Invoices and open directly to the invoice report header (" owes €X") with no Join button. No console or network errors related to the flow.
Second invoice report opened while offline, no Join button

Step Status
Newly sent invoice row is listed on Spend > InvoicesAfter sending a €25.00 invoice via FAB > Send invoice, the Invoices list shows one row: Sep 1, Outstanding, To invoicetestrecipient+…, €25.00.
Invoices list showing the newly sent invoice row
Clicking the invoice row opens the invoice report (not a transaction thread), with no Join buttonHeader shows "invoicetestrecipient+… owes €25.00" with Outstanding status and a compose box (report view). A selector probe for role=button label="Join" returned no match.
Invoice report header with no Join button
While offline, the newly created invoice's row opens the invoice report with no Join buttonForce offline enabled via Account > Troubleshoot. Created a second €10.00 invoice via FAB while offline; it appeared in Spend > Invoices and opened the invoice report "invoicetestrecipient+… owes €10.00", not a transaction thread, with no Join button.
Invoices list with two rows while offline
Second invoice report opened while offline, no Join button
No JS console errors related to this flowNetwork dump showed only one unrelated 403 for POST /api/AuthenticatePusher (background Pusher auth). All SendInvoice, OpenReport and Search calls returned 200.

Code review

The fix works and is low risk. Both halves check out: buildOptimisticInvoiceReport has a single caller (SendInvoice.ts:684) which builds exactly one transaction and never routes through the transactionCount increment in MoneyRequestBuilder.ts:1520, so there is no double count. The canJoinChat clause can only remove a Join button, never add one. test (job 3) fails on tests/unit/CloudflareSessionTest.ts with ReferenceError: Request is not defined — unrelated to this PR.

Four things worth addressing before merge:

1. The test steps don't cover the reported repro. Issue #98882 reproduces online in production, but the Tests section only exercises the offline path. Add the original steps (send an invoice, then click it on the Spend tab while online) so a reviewer verifies the bug that was actually filed.

2. Open question: does the backend return transactionCount on INVOICE reports? The optimistic report is written with Onyx.METHOD.SET at SendInvoice.ts:164-175 and the client generates the reportID itself, so a server merge that omits transactionCount preserves the optimistic 1 for the session. But after a reload or on a second device, isOneTransactionReport goes false again and the Spend row navigates back to the transaction thread. The Join button would stay gone (the canJoinChat half covers that), but the destination would be wrong again. I could not confirm the backend payload from this repo — worth checking with an internal engineer.

3. isInvoiceReport(parentReport) is broader than its siblings. isIOURequest/isExpenseRequest gate on the parent report type and isTransactionThread(parentReportAction). The new clause has no action gate, so it also suppresses Join on plain comment threads under an invoice report — and for a hidden thread, Join is the only UI that un-hides it, since DynamicReportDetailsPage.tsx:463 also hides the notification-preference row. Minimum change: add the isTransactionThread(parentReportAction) gate.

Why the root cause arguably sits one layer up

isMoneyRequest / isReportTransactionThread don't know about type === INVOICE, so ReportHeader.tsx:46 sends an invoice transaction thread to HeaderView instead of MoneyRequestHeaderHeaderView is the only place the Join button renders. An isInvoiceRequest helper alongside isIOURequest/isExpenseRequest, folded into isMoneyRequest, fixes the header structurally and makes the canJoinChat patch unnecessary. Same gap shows up in MoneyRequestReportView.tsx:163, MoneyRequestReportUtils.ts:138 and useReportActionsPagination.ts:71. Caveat: broadening isMoneyRequest touches ~15 call sites, so it is a much larger review surface than this one-liner — reasonable to keep the narrow fix here and file the rest separately.

4. The new unit test doesn't test what its name says. ReportUtilsTest.ts:13167 is named "transaction thread under an invoice report" but passes undefined for parentReportAction, so it never builds a transaction action — it asserts "any thread under an invoice parent". Either build a real CONST.IOU.REPORT_ACTION_TYPE.CREATE parent action or rename the test.


view run

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Web test steps verification results: ⚠️ partial

Normal expense flow and the invoice report's transaction list are unaffected; deleting the invoice's only expense removes the whole invoice report, as it does for any single-expense report. The invoice comment-thread step was blocked by sandbox backend failures, so the one regression below is code-level only.
Invoice chat stuck in error state with no composer

Step Status
Normal (non-invoice) workspace expense still opens correctly from SpendSubmitted a €40 Taxi expense, opened Spend > Expenses and clicked the row: the expected expense view rendered (Amount, Merchant, Category, Date, Report), no Join button, no error.
Normal workspace expense opened from Spend, no Join button
Invoice report shows its single expense — no stuck skeleton, no empty listAmount, merchant and date rendered immediately in the invoice report.
Invoice report showing its expense
Invoice report transaction detail
Delete the invoice's expense, then reopen the invoiceDeleting the sole expense deleted the whole invoice report and fell back to the empty 1:1 chat — the same behavior every single-expense report has. Separately, a stale "Invoices" entry left in the Send invoice recents list still pointed at the deleted invoice and led to a "not here" page; that path is untouched by this diff and was not compared against main, so it is not attributed to this PR.
After deleting the invoice's only expense
Spend Invoices tab after deletion
Stale Invoices entry in the Send invoice recents list
Not found page reached from the stale recents entry
⚠️
Open a comment thread inside the invoice report and check its headerBlocked. Repeated invoice sends were rejected server-side with "Company website is invalid" for every URL tried, and AuthenticatePusher returned 403 throughout, so the invoice chat never rendered a composer or a "Reply in thread" affordance. Sandbox limitation, not app code.
Invoice chat stuck in error state with no composer
⚠️
No JS console errorsNo crashes or white screens. The network dump showed only the environment-level AuthenticatePusher 403s and the invoice-send validation rejection, which the UI displayed correctly as an error banner.
⚠️

One regression found

Comment threads under an invoice report lose their Join button. ReportUtils.ts:12064-12070 has no isTransactionThread(parentReportAction) gate, so it suppresses Join on every chat thread under an invoice report, not just transaction threads. Its siblings isIOURequest/isExpenseRequest do require that gate, which is why comment threads under expense and IOU reports still show Join. Fix: change the clause to isInvoiceReport(parentReport) && isTransactionThread(parentReportAction).

Reachable two-person flow, and why the severity is low
  1. Sender A comments in the invoice report and replies in thread to their own message. createChildReport sets the thread participants to [A] only (Report/index.ts:2860).
  2. Receiver B taps "1 reply". B is not a thread participant, so getChildReportNotificationPreference returns HIDDEN, which is exactly the state that makes canJoinChat reach the changed line.
  3. On main B sees Join; on this branch B does not.

Severity is low: the "Join thread" context-menu action on the parent message still works (ContextMenuActions.tsx:778), and posting a comment auto-unhides the thread. The Join button is the only thing lost — canJoin gates nothing else at either call site (header button in HeaderView.tsx, promoted-action pill in DynamicReportDetailsPage.tsx).

This is also why the new unit test would not catch it: it passes undefined for parentReportAction, so it asserts the over-broad behavior rather than the transaction-thread case.

Checked and ruled out — no regression in these
  • Search row actions. Invoice reports are deliberately let past the money-request gate at SearchUIUtils.ts:2559, so transactionCount: 1 now lets an invoice transaction row past the isOneTransactionReport short-circuit at :2577. No new button appears: Pay requires being the invoice receiver or their policy admin (ReportWorkflow.ts:236-243) and the optimistic report only exists on the sender's device, while Export is gated && !isTransaction (:2546). Approve/Submit/Change approver all require isExpenseReport.
  • Report preview skeleton. MoneyRequestReportPreview/index.tsx:147-152 uses expectedTransactionCount only to gate the new-expense highlight, not the list — confirmed on web, the expense rendered immediately.
  • Deleting the expense. The sole-expense case sets the invoice report to null (DeleteMoneyRequest.ts:156), so there is no "count 1, zero transactions" stale state. Confirmed on web.
  • Moving the expense. Transaction.ts:1416 went from max(0, 0-1) to 1-1 — same result, now arithmetically correct.
  • Search list grouping. The isOneTransactionReport field on list items has no production writer, so GroupHeader/TransactionGroupListItem are unaffected.
  • No-ops and improvements. MoneyRequestHeader.tsx:128 (0 <= 11 <= 1); NextStepUtils, OptionsListUtils and submitDismissStrategies are gated on isExpenseReport/isMoneyRequestReport, which exclude invoices; the export "empty report" guard at useSearchBulkActions.ts:817 stops misclassifying a new invoice as empty.

Still open from the earlier review: nothing in SendInvoice's success or failure data ever clears transactionCount, so if the backend does not send it for INVOICE reports the value diverges permanently on the sender's device. Worth one internal check of the response payload.


view run

@luacmartins
luacmartins merged commit 77176c0 into Expensify:main Sep 1, 2026
46 of 49 checks passed
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🚧 luacmartins has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

OSBotify commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

OSBotify commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/luacmartins in version: 9.4.66-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes are required for this PR, so I did not create a docs PR.

This PR is a bug fix with no user-facing surface change: it adds transactionCount: 1 to buildOptimisticInvoiceReport so the Spend list opens the invoice report instead of the transaction thread, and adds isInvoiceReport(parentReport) to canJoinChat so the stray Join button no longer renders. No feature, setting, label, or documented step changes — it only removes broken behavior.

I checked the two articles that could plausibly describe this flow, and neither documents opening an invoice from the Spend page or the Join button:

Unrelated: two stale labels in the invoicing article

While verifying labels against the live UI, I found two mismatches in Send-an-Invoice.md. Both predate this PR, so I left them out of scope rather than bundling an unrelated docs change onto this fix.

Article says Live UI shows
line 15 — turn on the Invoice toggle Invoices (plural), under the Earn section
line 23 — select Send Invoice Send invoice (sentence case)

More features page: Earn section with the Invoices toggle

Global create menu showing Send invoice

nkdengineer — there is no help site PR to review or mark Ready for review, since this PR needs no docs update. If you want the two stale labels above corrected, reply @MelvinBot fix the invoicing article labels and I'll open a separate draft HelpDot PR for them.


view run

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.

5 participants