You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$250] [Exploratory] 91626-Chat-In a Read only conversation, user can add attachment #92679
The "+" Add additional receipt button on the receipt is gated only by a generic "can I write in this chat?" check, not by the receipt‑edit permission that every other receipt action uses.
where isEditable is just canUserPerformWriteAction(report) && !readonly.
For a user who was invited to the chat but is not the expense requestor, canUserPerformWriteAction returns true (they are allowed to comment in the DM), so isEditable is true and the "+" button renders. Pressing it calls addAttachmentWithComment, which posts the image into the conversation — exactly the reported behavior ("camera image is added to conversation").
The receipt‑specific permission canEditReceiptis already computed in this component (line 247 — it runs canEditFieldOfMoneyRequest({fieldToEdit: RECEIPT, …}), which requires the current user to be the requestor/manager/admin). That user fails canEditReceipt. The receipt image itself and the Expand button correctly respect it (readonly={readonly || !canEditReceipt} at line 687 and line 742) — but canShowReceiptActions for the "+" button does not. That inconsistency is the bug.
What changes do you think we should make in order to solve the problem?
Include canEditReceipt in the canShowReceiptActions condition at MoneyRequestReceiptView.tsx:541 so the "+" Add‑additional‑receipt button uses the same receipt‑edit permission as the receipt image and Expand button. A user who cannot edit the receipt will then no longer see (or be able to trigger) the add‑attachment action, matching the expected read‑only behavior.
Investigation details & alternatives considered
Why the generic gate is too weak here:canUserPerformWriteAction → canWriteInReport only reflects chat commenting rights, and additionally defaults to writable when report.permissions is empty. It says nothing about who may edit the expense/receipt. canEditReceipt (via canEditFieldOfMoneyRequest → canEditMoneyRequest in ReportUtils.ts) is the check that restricts receipt edits to the requestor/manager/admin, which is what should gate this button.
Alternative (defense in depth): the underlying actions addAttachmentWithComment (libs/actions/Report/index.ts) and replaceReceipt (libs/actions/IOU/Receipt.ts) perform no write‑access re‑validation, so the UI gate is the only client‑side protection. Server‑side enforcement would be the robust backstop, but the minimal client fix above resolves the reported UX.
Confidence: Medium‑high. Code path is confirmed; the exact runtime value of canEditReceipt for the invited user (expected false for a non‑requestor on an IOU report) is inferred from the code and worth a quick confirmation during implementation/testing.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/92679) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
Please re-state the problem that we are trying to solve in this issue.
In a read-only conversation, a user who cannot write in the conversation is still able to add an attachment to an expense. Opening the expense and using the "add additional receipt" (+) button on the receipt lets the user attach a camera image, which is posted to the conversation. The expected behavior is that a user who cannot write in a read-only conversation must not be able to add an attachment.
What is the root cause of that problem?
A read-only conversation enforces its restriction on the conversation (chat) report — through that report's permissions / writeCapability. The conversation's own composer correctly respects this because ReportFooter hides the composer based on canUserPerformWriteAction evaluated against the chat report:
The expense receipt view, however, derives its editability from the wrong report. In MoneyRequestReceiptView, the isEditable flag is computed only from canUserPerformWriteAction(report), where report is the transaction thread report (the expense detail), not the parent conversation report:
The transaction thread report does not carry the conversation's read-only restriction, so canUserPerformWriteAction returns true for it (canWriteInReport returns true when the report has no restricting permissions):
and the add-attachment (+) button posts the attachment to the conversation through addAttachmentWithComment, even though the current user cannot write in that conversation:
What changes do you think we should make in order to solve the problem?
Make the receipt view's editability conversation-aware, so it mirrors how the conversation's composer is gated.
In MoneyRequestReceiptView, in addition to the existing canUserPerformWriteAction(report) check used to compute isEditable, also require that the current user can write in the parent conversation (chat) report. The component already loads the chat report and computes its archived state:
So isEditable (line 217) should additionally require canUserPerformWriteAction(chatReport, isChatReportArchived) to be true when a chat report is present. Guard the new condition on the chat report being available, so contexts where there is no parent conversation report (or while data is still loading) are unaffected.
With this change, canShowReceiptActions becomes false for a user who cannot write in the read-only conversation, so the add-attachment (+) button is hidden and the attachment write through addAttachmentWithComment is no longer reachable — matching how ReportFooter already hides the conversation composer for the same user. This also keeps the other edit affordances guarded by isEditable consistent with the read-only conversation.
What alternative solutions did you explore? (Optional)
Gate only the add-attachment button (i.e. canShowReceiptActions) on the conversation write permission rather than folding it into isEditable. This fixes the reported symptom but leaves the remaining edit affordances inconsistent with the read-only conversation, so extending isEditable is the cleaner, more complete fix.
Add the write-permission check inside the attachment-add handler (onAttachmentFilesValidated) instead of the visibility check. This would block the write but still display a non-functional (+) button to the user, which is a worse experience than hiding the control.
changed the title [-][Due for payment 2026-09-15] [$250] [Exploratory] 91626-Chat-In a Read only conversation, user can add attachment[/-][+][$250] [Exploratory] 91626-Chat-In a Read only conversation, user can add attachment[/+]on Sep 21, 2026
Activity
applause-bot commentedon Jun 4, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/67471738fae2bc9fb9d643c4878782ca9dee7f416cb3f435a6793571b576cd23
MelvinBot commentedon Jul 17, 2026
Proposal
What is the root cause of that problem?
The "+" Add additional receipt button on the receipt is gated only by a generic "can I write in this chat?" check, not by the receipt‑edit permission that every other receipt action uses.
In
MoneyRequestReceiptView.tsx:541the button's visibility is:where
isEditableis justcanUserPerformWriteAction(report) && !readonly.For a user who was invited to the chat but is not the expense requestor,
canUserPerformWriteActionreturnstrue(they are allowed to comment in the DM), soisEditableistrueand the "+" button renders. Pressing it callsaddAttachmentWithComment, which posts the image into the conversation — exactly the reported behavior ("camera image is added to conversation").The receipt‑specific permission
canEditReceiptis already computed in this component (line 247 — it runscanEditFieldOfMoneyRequest({fieldToEdit: RECEIPT, …}), which requires the current user to be the requestor/manager/admin). That user failscanEditReceipt. The receipt image itself and the Expand button correctly respect it (readonly={readonly || !canEditReceipt}at line 687 and line 742) — butcanShowReceiptActionsfor the "+" button does not. That inconsistency is the bug.What changes do you think we should make in order to solve the problem?
Include
canEditReceiptin thecanShowReceiptActionscondition atMoneyRequestReceiptView.tsx:541so the "+" Add‑additional‑receipt button uses the same receipt‑edit permission as the receipt image and Expand button. A user who cannot edit the receipt will then no longer see (or be able to trigger) the add‑attachment action, matching the expected read‑only behavior.Investigation details & alternatives considered
canUserPerformWriteAction→canWriteInReportonly reflects chat commenting rights, and additionally defaults to writable whenreport.permissionsis empty. It says nothing about who may edit the expense/receipt.canEditReceipt(viacanEditFieldOfMoneyRequest→canEditMoneyRequestinReportUtils.ts) is the check that restricts receipt edits to the requestor/manager/admin, which is what should gate this button.addAttachmentWithComment(libs/actions/Report/index.ts) andreplaceReceipt(libs/actions/IOU/Receipt.ts) perform no write‑access re‑validation, so the UI gate is the only client‑side protection. Server‑side enforcement would be the robust backstop, but the minimal client fix above resolves the reported UX.canEditReceiptfor the invited user (expectedfalsefor a non‑requestor on an IOU report) is inferred from the code and worth a quick confirmation during implementation/testing.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/92679)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
melvin-bot commentedon Jul 17, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Krishna2323 (
External)wildan-m commentedon Jul 17, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
In a read-only conversation, a user who cannot write in the conversation is still able to add an attachment to an expense. Opening the expense and using the "add additional receipt" (+) button on the receipt lets the user attach a camera image, which is posted to the conversation. The expected behavior is that a user who cannot write in a read-only conversation must not be able to add an attachment.
What is the root cause of that problem?
A read-only conversation enforces its restriction on the conversation (chat) report — through that report's
permissions/writeCapability. The conversation's own composer correctly respects this becauseReportFooterhides the composer based oncanUserPerformWriteActionevaluated against the chat report:App/src/pages/inbox/report/ReportFooter.tsx
Lines 76 to 77 in 8ea16a6
The expense receipt view, however, derives its editability from the wrong report. In
MoneyRequestReceiptView, theisEditableflag is computed only fromcanUserPerformWriteAction(report), wherereportis the transaction thread report (the expense detail), not the parent conversation report:App/src/components/ReportActionItem/MoneyRequestReceiptView.tsx
Lines 216 to 217 in 8ea16a6
The transaction thread report does not carry the conversation's read-only restriction, so
canUserPerformWriteActionreturns true for it (canWriteInReportreturns true when the report has no restrictingpermissions):App/src/libs/ReportUtils.ts
Lines 2436 to 2442 in 8ea16a6
Because
isEditableis true, the receipt action buttons are shown viacanShowReceiptActions:App/src/components/ReportActionItem/MoneyRequestReceiptView.tsx
Line 509 in 8ea16a6
and the add-attachment (+) button posts the attachment to the conversation through
addAttachmentWithComment, even though the current user cannot write in that conversation:App/src/components/ReportActionItem/MoneyRequestReceiptView.tsx
Lines 645 to 684 in 8ea16a6
What changes do you think we should make in order to solve the problem?
Make the receipt view's editability conversation-aware, so it mirrors how the conversation's composer is gated.
In
MoneyRequestReceiptView, in addition to the existingcanUserPerformWriteAction(report)check used to computeisEditable, also require that the current user can write in the parent conversation (chat) report. The component already loads the chat report and computes its archived state:App/src/components/ReportActionItem/MoneyRequestReceiptView.tsx
Line 139 in 8ea16a6
App/src/components/ReportActionItem/MoneyRequestReceiptView.tsx
Line 179 in 8ea16a6
So
isEditable(line 217) should additionally requirecanUserPerformWriteAction(chatReport, isChatReportArchived)to be true when a chat report is present. Guard the new condition on the chat report being available, so contexts where there is no parent conversation report (or while data is still loading) are unaffected.With this change,
canShowReceiptActionsbecomes false for a user who cannot write in the read-only conversation, so the add-attachment (+) button is hidden and the attachment write throughaddAttachmentWithCommentis no longer reachable — matching howReportFooteralready hides the conversation composer for the same user. This also keeps the other edit affordances guarded byisEditableconsistent with the read-only conversation.Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/92679-readonly-receipt-attachment?expand=1
What alternative solutions did you explore? (Optional)
canShowReceiptActions) on the conversation write permission rather than folding it intoisEditable. This fixes the reported symptom but leaves the remaining edit affordances inconsistent with the read-only conversation, so extendingisEditableis the cleaner, more complete fix.onAttachmentFilesValidated) instead of the visibility check. This would block the write but still display a non-functional (+) button to the user, which is a worse experience than hiding the control.55 remaining items
melvin-bot commentedon Sep 14, 2026
Payment Summary
Resolving PRs:
Upwork Job
BugZero Checklist (@mallenexpensify)
melvin-bot commentedon Sep 17, 2026
@mallenexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
mallenexpensify commentedon Sep 18, 2026
Payment Summary
Contributor: @wildan-m paid $250 via Upwork
Contributor+: @Krishna2323 due $250 via NewDot
@wildan-m paid, summary updated above. Thx.
https://www.upwork.com/jobs/~022101091393205791964
wildan-m commentedon Sep 19, 2026
@mallenexpensify uw contract accepted
[-][Due for payment 2026-09-15] [$250] [Exploratory] 91626-Chat-In a Read only conversation, user can add attachment[/-][+][$250] [Exploratory] 91626-Chat-In a Read only conversation, user can add attachment[/+]mallenexpensify commentedon Sep 21, 2026
@wildan-m paid, summary updated above. Thx.
laurenreidexpensify commentedon Sep 24, 2026
$250 Approved @Krishna2323 New Expensify