Hide receipt attachment actions when the parent conversation is read-only - #97423
Hide receipt attachment actions when the parent conversation is read-only#97423wildan-m wants to merge 8 commits into
Conversation
…ly-receipt-attachment
…ly-receipt-attachment
…ly-receipt-attachment
|
@Krishna2323 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] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cbc493be1c
ℹ️ 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".
| // A conversation's read-only restriction lives on the parent conversation report, not on the transaction thread, | ||
| // so checking the thread alone lets someone who cannot post in the conversation still attach a receipt to it. | ||
| // Mirrors how the conversation composer is gated. Skipped when there is no parent conversation to check. | ||
| const canWriteInChatReport = !chatReport || !!canUserPerformWriteActionReportUtils(chatReport, isChatReportArchived); |
There was a problem hiding this comment.
Require the parent chat to load before enabling uploads
When parentReport?.parentReportID is already known but that chat report has not hydrated yet (for example after opening the transaction from search/deep link or after clearing Onyx), !chatReport makes this guard treat the parent conversation as writable. That leaves the receipt actions enabled for a read-only parent chat until the chat report arrives, so a user with only READ permission can still press Add additional receipt and send addAttachmentWithComment before the guard flips. Please only skip this check when there is truly no parent conversation, not when the expected parent chat is missing from Onyx.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — fixed in b25e1ea: a report above the expense that is expected but not yet in Onyx now blocks the add button until it loads, instead of reading as writable.
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
Explanation of Change
In a read-only conversation, someone who cannot post there can still add an attachment to an expense — opening the expense and using the receipt's add-additional-receipt control attaches an image that lands in the conversation. The restriction that makes a conversation read-only is carried on the report the user was given limited access to, which here is the expense's own report. The receipt view is handed the transaction thread below it and decides editability from that alone; the thread carries no restriction, so the control stays visible and the attachment goes through.
Editability now also requires write permission on the reports above the expense — its own report and the conversation above it — using the same permission check that hides the conversation composer. Only the add control is gated: the expand control still renders, so someone who cannot post can still open the receipt to read it, exactly as they can today.
Fixed Issues
$ #92679
PROPOSAL: #92679 (comment)
Tests
Offline tests
This is a visibility check computed from conversation data that is already cached locally, and it adds no network request. Offline, the add-additional-receipt control is hidden or shown from that cached data exactly as it is online: hidden in a read-only conversation, offered in one the user can post in.
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Kapture.2026-07-31.at.10.43.04.mp4
Android: mWeb Chrome
Kapture.2026-07-31.at.10.46.06.mp4
iOS: Native
Kapture.2026-07-31.at.10.53.10.mp4
iOS: mWeb Safari
Kapture.2026-07-31.at.10.54.48.mp4
MacOS: Chrome / Safari
Kapture.2026-07-31.at.10.47.15.mp4