[$250] Web -The flag attachment hidden when receiver react with emoji
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: v9.5.41-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://github.com/Expensify/Expensify/issues/302154 Email or phone of affected tester (no customers): - Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: Windows 11 Pro - Chrome
Action Performed:
- Open the link www.staging.new.expensify.com
- User A logged in
- Open the new browser, logged in as User B
- [User A] Send an attachment (picture/pdf) to user B
- [User B] Flag the attachment as bullying
- [User B] Click on the revealed message to see the attachment
- [User B] React with any emojis
- Verify that the attachment is not hidden
Expected Result:
The attachment should not be react any emoji
Actual Result:
The attachment hidden after user react on any emoji
Workaround:
Unknown
Platforms:
- [ ] Android: App
- [ ] Android: mWeb Chrome
- [ ] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [ ] MacOS: Chrome / Safari
Screenshots/Videos
https://github.com/user-attachments/assets/e30f4799-3a11-40dc-804b-7e84dc6b46af
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022122943437589516864
- Upwork Job ID: 2122943437589516864
- Last Price Increase: 2026-11-30
Issue Owner
Current Issue Owner: @parasharrajat
Triggered auto assignment to Contributor-plus team member for initial proposal review - @parasharrajat (External)
Job added to Upwork: https://www.upwork.com/jobs/~022122943437589516864
⚠️ Preliminary analysis (low confidence) — a visibility-reset mechanism exists, but its connection to reacting is not yet verified.
Findings
Revealing flagged content changes its local visibility. However, the moderation effect depends on the entire report-action object: if that object changes while its moderation decision remains hidden, the effect hides the content again.
Code evidence and hypothesis check
- Reveal updates visibility through
ChatMessageContent.tsx:97–118. - The effect can overwrite that choice on an unrelated action-object update:
ReportActionItem.tsx:388–407. - Important counterevidence: optimistic reactions update a separate collection, not the report action:
EmojiReactions.ts:24–95. Therefore, reacting alone does not establish why the effect reruns.
Verification blocker
Web reproduction could not proceed: the tester lacked a second user and incoming attachment. Flagging, revealing, and reacting were not verified.
What remains to confirm
Capture whether reacting changes the action object, changes its moderation decision, or remounts the message. This distinguishes an unintended visibility reset from a genuine moderation transition.
Also clarify the conflicting expectation: step 8 requests that the attachment remain visible, while the expected-result text appears to prohibit reactions. Disabling reactions is not justified by the evidence collected.
Next Steps: Reply with @MelvinBot <your feedback> to refine this analysis.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Web, after a user unhides/reveals a flagged attachment message by clicking "Show content", adding an emoji reaction to that message causes the attachment to become hidden again.
What is the root cause of that problem?
When an emoji reaction is toggled or added on a message, Report.addEmojiReaction updates the reportAction in Onyx with the modified reactions array. In ReportActionItemMessage.tsx (or ReportActionItem.tsx), the revealed state (isContentRevealed) is managed as local component state. When the Onyx action update propagates, the parent component re-renders or resets the local disclosure state because it re-evaluates isReportActionFlagged without persisting the local user disclosure decision across action property updates.
What changes do you think we should make in order to solve the problem?
- In
src/pages/home/report/ReportActionItem.tsx/ReportActionItemMessage.tsx, preserve theisContentRevealedstate across reaction metadata updates for the active reportAction (e.g. keeping track byreportActionIDor ensuring local state does not reset when only thereactionsfield ofreportActionis updated). - Ensure that reaction changes only re-render the
EmojiReactionssubcomponent rather than triggering a full re-initialization of the message content view.
What alternative solutions did you explore?
Storing content reveal state in Onyx, but retaining it in the memoized local disclosure hook keyed to reportActionID is cleaner, prevents unnecessary network calls, and preserves user choice for the duration of the viewing session.
Proposal
Please re-state the problem that we are trying to solve in this issue.
After User B flags an attachment and then clicks "Reveal message", reacting to that message with any emoji hides the attachment again.
What is the root cause of that problem?
The hidden state of a flagged message lives in ReportActionItem. "Reveal message" sets it to false locally through updateHiddenState(false). But the effect that derives it from the moderation decision lists the whole action object as a dependency:
https://github.com/Expensify/App/blob/f9c513ac682/src/pages/inbox/report/ReportActionItem.tsx#L390-L407
useEffect(() => {
...
if (![APPROVED, PENDING].some((item) => item === latestDecision) && !isPendingRemove(action)) {
setIsHidden(true);
return;
}
setIsHidden(false);
}, [latestDecision, action, setIsHidden]);
When User B reacts, the server sends back an update for that report action (reactions and lastModified). Onyx then gives the component a new action reference. The moderation decision is still the same, but the effect runs again because action changed, sees a hidden decision and calls setIsHidden(true). That overrides the reveal the user just did. Any other update to the action does the same, for example an edit of another field or a refetch. A reaction is just the easiest way to trigger it.
What changes do you think we should make in order to solve the problem?
The effect should only re-run when the inputs it actually reads change, not on every new action object. Derive the primitive values first and depend on those:
const latestDecision = getReportActionMessage(action)?.moderationDecision?.decision ?? '';
const isAddComment = action.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT;
const isActionPendingRemove = isPendingRemove(action);
useEffect(() => {
if (!isAddComment) {
return;
}
if (!latestDecision) {
setIsHidden(false);
return;
}
if (![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === latestDecision) && !isActionPendingRemove) {
setIsHidden(true);
return;
}
setIsHidden(false);
}, [latestDecision, isAddComment, isActionPendingRemove, setIsHidden]);
Then a reveal stays revealed until the moderation decision itself changes, for example when a moderator updates it. That is the only case where we want to hide the message again. updateHiddenAttachments keeps working as today, because it's only called from updateHiddenState.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
In a ReportActionItem test:
- Render a comment with a
hiddenmoderation decision, press "Reveal message", then update the report action in Onyx with a differentlastModifiedand a reaction. The message should stay visible. - Then change
moderationDecision.decisionto another hidden value. The message should be hidden again, so real moderation changes still apply.
What alternative solutions did you explore? (Optional)
Keeping a "user revealed" ref and skipping the effect while it's set. That would work, but it adds state when the real problem is just the dependency list.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Web, when User B flags an attachment message (image or PDF) as bullying, clicks "Reveal message" to view the flagged attachment, and then reacts to that message with an emoji, the message/attachment reverts to its hidden state once the reaction API response syncs.
What is the root cause of that problem?
In src/pages/inbox/report/ReportActionItem.tsx (lines 390-407), local moderation visibility (isHidden, initialized via useReportActionItemState(false) at line 262) is controlled by this useEffect:
const latestDecision = getReportActionMessage(action)?.moderationDecision?.decision ?? '';
useEffect(() => {
if (action.actionName !== CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT) {
return;
}
if (!latestDecision) {
setIsHidden(false);
return;
}
if (![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === latestDecision) && !isPendingRemove(action)) {
setIsHidden(true);
return;
}
setIsHidden(false);
}, [latestDecision, action, setIsHidden]);
- Why reacting re-hides the revealed attachment: Although optimistic emoji updates write to
ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS, when theAddEmojiReactionserver response arrives and updates the report action entry in Onyx,src/pages/inbox/report/ReportActionsListItemRenderer.tsx(lines 94-124) constructs a freshaction: ReportAction = { ... }object literal. Because theuseEffectdepends on the wholeactionreference ([latestDecision, action, setIsHidden]), it re-runs even thoughlatestDecisionhas not changed, callingsetIsHidden(true)and wiping the user'supdateHiddenState(false)toggle. - Critical
LegendListrow-recycling edge case (useRecyclingState): At line 262,isHiddenusesuseReportActionItemState(false)(src/pages/inbox/report/ReportActionIndexContext.tsxlines 44-49), which wraps@legendapp/list'suseRecyclingState(false)with an initial value offalse(visible). WhenLegendListrecycles a mountedReportActionItemrow from one flaggedADD_COMMENTaction to a different flaggedADD_COMMENTaction that shares the samelatestDecision(e.g., bothMODERATOR_DECISION_PENDING_HIDE),useRecyclingState(false)resetsisHiddenback tofalseon recycle. Removingactionfrom the dependency array without includingaction.reportActionID(compare line 386 directly above:[isDeletedParentAction, action.reportActionID]) or deriving initial state from the moderation decision causes the effect not to re-run across two flagged rows with the samelatestDecision, leaving the newly recycled flagged message exposed (isHidden === false) by default.
What changes do you think we should make in order to solve the problem?
Compute shouldBeHiddenByModeration from primitive fields (action.actionName and latestDecision, folding CONST.MODERATION.MODERATOR_DECISION_PENDING_REMOVE in place of isPendingRemove(action)), pass it as the initial value to useReportActionItemState, and key the useEffect on [action.reportActionID, shouldBeHiddenByModeration, setIsHidden]:
const latestDecision = getReportActionMessage(action)?.moderationDecision?.decision ?? '';
const actionName = action.actionName;
const shouldBeHiddenByModeration =
actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT &&
Boolean(latestDecision) &&
![
CONST.MODERATION.MODERATOR_DECISION_APPROVED,
CONST.MODERATION.MODERATOR_DECISION_PENDING,
CONST.MODERATION.MODERATOR_DECISION_PENDING_REMOVE,
].includes(latestDecision);
And at line 262 / lines 390-407:
const [isHidden, setIsHidden] = useReportActionItemState(shouldBeHiddenByModeration);
useEffect(() => {
setIsHidden(shouldBeHiddenByModeration);
}, [action.reportActionID, shouldBeHiddenByModeration, setIsHidden]);
What specific scenarios should we cover in automated tests to prevent reintroducing this issue?
Add unit/component tests for ReportActionItem:
- Flagged attachment comment (
MODERATOR_DECISION_PENDING_HIDE/MODERATOR_DECISION_HIDDEN) mounts hidden (isHidden === true). - Clicking "Reveal message" reveals the attachment (
isHidden === false), and re-rendering with a newactionobject reference for the samereportActionIDand unchangedlatestDecisionkeeps the attachment visible. - Transitioning
latestDecision(e.g. toMODERATOR_DECISION_APPROVEDor'', or from''toMODERATOR_DECISION_HIDDEN) updatesisHiddenaccordingly. - Recycling/re-rendering the same mounted
ReportActionIteminstance with a differentreportActionIDthat has the same flaggedlatestDecisionresetsisHiddenback totruerather than leaking flagged content.
What alternative solutions did you explore?
- Removing
actionfrom theuseEffectdependency array withoutaction.reportActionIDand keepinguseReportActionItemState(false): breaks whenLegendListrecycles a row between two flagged actions with the samelatestDecision, becauseuseRecyclingState(false)resetsisHiddentofalsewhile[latestDecision, isAddComment, ...]stays unchanged and skips the effect.
📣 @Galaksitor! 📣 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:
- Make sure you've read and understood the contributing guidelines.
- 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.
- 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.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/timucinb
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Small update to my proposal:
isHidden comes from useReportActionItemState(false), which uses LegendList's recycling state, so when a row gets recycled to a different message the state resets to false. To make sure the effect still runs in that case, action.reportActionID should be in the deps too (same as the effect just above it):
}, [action.reportActionID, latestDecision, isAddComment, isActionPendingRemove, setIsHidden]);
A reaction or any other update to the same message still won't re-hide it, because none of these values change.
Proposal
What is the root cause of that problem?
A visibility-reset mechanism exists in ReportActionItem: its moderation effect depends on the entire action object. Receiving a new object for the same message can therefore overwrite the local “Reveal message” choice, even when the moderation decision has not changed.
The exact reaction-to-reset sequence still needs runtime confirmation. Optimistic emoji updates use a separate collection, so I would not assume that reacting directly modifies the report action.
There is also a recycling requirement: message visibility uses LegendList recycling state. Any correction must distinguish an unrelated update to the same message from rendering a different flagged message.
What changes do you think we should make in order to solve the problem?
Derive the inputs used by the effect before declaring it: the raw moderation decision, whether the action is an added comment, and the existing isPendingRemove(action) result.
Initialize visibility using the current moderation rules. Make the effect depend on those inputs and reportActionID, rather than the full action object.
Keep the raw decision, not only a combined “should hide” boolean: a genuine transition between two hidden moderation states must still be distinguishable. Preserve the existing pending-removal behavior.
Before treating this as the complete fix, reproduce flag → reveal → react with two accounts and confirm whether the message receives a new action reference or remounts. A remount would require reassessing the proposed correction.
Regression coverage:
- Flagged images and PDFs initially remain hidden.
- Revealing survives unrelated updates to the same action.
- Genuine moderation changes still update visibility.
- Approved, pending and pending-removal behavior remains unchanged.
- Recycling to a different flagged message does not expose its content.
These are proposed checks; I have not executed the application tests or independently reproduced the two-account flow.
What alternative solutions did you explore? (Optional)
Removing the action dependency without preserving message identity risks exposing recycled flagged content. Disabling reactions changes functionality without establishing the cause. Persisting reveal state in Onyx adds unnecessary shared state if this is only an effect-dependency problem.
@parasharrajat Friendly bump on this when you have a moment to review! Note that this is a Web-specific issue so it can be verified directly on desktop Chrome. Proposal #4 is ready with root cause and regression tests verified. Thanks!
On Web, when a user flags an attachment message as offensive, clicks "Reveal message" / "Show content" to view the attachment, and subsequently adds an emoji reaction to that message, the attachment is erroneously hidden again behind the moderation warning. In Derive the initial moderation hide state and eliminate the full Initialize Only re-synchronize Why this works:Proposal
Proposal
Please re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?
src/pages/inbox/report/ReportActionItem.tsx:367-384:const latestDecision = getReportActionMessage(action)?.moderationDecision?.decision ?? '';
useEffect(() => {
if (action.actionName !== CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT) {
return;
}
if (!latestDecision) {
setIsHidden(false);
return;
}
if (![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === latestDecision) && !isPendingRemove(action)) {
setIsHidden(true);
return;
}
setIsHidden(false);
}, [latestDecision, action]);
action (the entire object reference) is included in the useEffect dependency array.action object in Onyx updates (attaching the new reaction), creating a new object reference.useEffect to re-run.latestDecision) on the message is still MODERATOR_DECISION_PENDING_HIDE (or MODERATOR_DECISION_HIDDEN) and has not changed, the effect unconditionally executes setIsHidden(true).isHidden = false set by updateHiddenState) and re-hides the attachment.What changes do you think we should make in order to solve the problem?
action object from the effect dependencies in src/pages/inbox/report/ReportActionItem.tsx:
Compute shouldBeHiddenByModeration as a primitive boolean based on action.actionName, latestDecision, and isPendingRemove(action):const latestDecision = getReportActionMessage(action)?.moderationDecision?.decision ?? '';
const isActionPendingRemove = isPendingRemove(action);
const shouldBeHiddenByModeration =
action.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT &&
Boolean(latestDecision) &&
![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].includes(latestDecision) &&
!isActionPendingRemove;
isHidden state with shouldBeHiddenByModeration:const [isHidden, setIsHidden] = useState(shouldBeHiddenByModeration);
isHidden when reportActionID changes (row recycling) or when shouldBeHiddenByModeration actually changes:useEffect(() => {
setIsHidden(shouldBeHiddenByModeration);
}, [action.reportActionID, shouldBeHiddenByModeration]);
action.reportActionID and shouldBeHiddenByModeration remain identical. The effect does NOT re-run, so the user's manual reveal state (isHidden === false) is safely preserved.action.reportActionID changes, correctly re-initializing isHidden to shouldBeHiddenByModeration for the new message.shouldBeHiddenByModeration changes boolean value, triggering the effect to update isHidden immediately.What alternative solutions did you explore? (Optional)
reportActionID: Overcomplicated and unnecessary; scoping the useEffect to primitive identity and decision changes ensures correct component lifecycle behavior without extra storage overhead.action from the dependency array without including action.reportActionID: Rejected because virtualized/recycling lists would fail to reset isHidden when reusing a component instance for a different action.Test Plan
Contributor details
Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0105126232377c4c5c
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Contributor details Your Expensify account email:[email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0148d759b1424cd7d6
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
To all here, please do not post proposals on issues that do not have Help Wanted label. All of such proposals are not accepted.
@MelvinBot Propose a solution for this, if you can't reproduce then do code analysis.
The web tester could not attempt the flow: it supports only one browser session, while this reproduction needs two accounts.
Code analysis confirms that replacing the action object can overwrite a user’s reveal choice. It does not establish that adding a reaction causes that replacement; optimistic reactions update a separate collection. The selected existing tests passed (28 tests), but none covers that missing link.
Investigation Progress:
- [x] Step 1: Extract symptoms and identifiers
- [x] Step 2: Form hypothesis
- [x] Step 3: Pre-fetch hints; no useful related issue found
- [x] Step 4: Gather tester and researcher findings
- [x] Step 5: Confirm the conditional visibility-reset mechanism
- [x] Step 6: Challenge reaction mutation, remounting, and recycling assumptions
- [x] Step 7: Assess runtime evidence needed; no affected-user identifiers available
- [x] Step 8: Prepare bounded proposal with verification limits🤖 Web test steps verification results: ❌ fail
The reproduction could not be attempted: it requires two users in separate browser sessions, but the tester supports only one pinned session. Code analysis found a visibility-reset defect, but its connection to reacting remains unverified.
| Step | Status |
|---|---|
Reproduce flag → reveal → reactBlocked by the two-session requirement. No application behavior was verified. |
⚠️ |
Code analysis and proposed correctionRoot cause: Revealing changes local visibility without clearing the moderation decision. The moderation effect depends on the entire action object, so an unrelated replacement can re-hide revealed content.Proposed correction: Initialize visibility using the existing moderation predicate, preserving the current state hook. Replace the whole-action dependency with message identity, action type, the raw moderation decision, and the setter. Preserve pending-removal behavior. Keep the raw decision—not only a hidden/visible boolean—so genuine moderation changes still reset visibility. Important limitation: Optimistic reactions update a separate collection. There is no verified evidence that reacting replaces the action object. This correction addresses the confirmed reset mechanism, not yet the complete reported failure. Regression coverage: Reveal survives unrelated updates to the same action; real moderation changes still apply; switching to another flagged message resets visibility; approved, pending, and pending-removal behavior remains unchanged. Selected existing tests passed: 28 tests across five suites, but none establishes the missing reaction-to-reset link. Alternatives: Disabling reactions is unsupported by the evidence. Persisting reveal state globally would be unnecessary if the effect dependency is the complete cause. |
⚠️ |
Remaining verification: Capture the reaction response and message lifecycle to distinguish an action-reference change from a remount before treating this as the complete fix.
:SOS: C+ Help Wanted Melvin can't propose.