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
[Due for payment 2025-04-16] [$250] Chat - Hidden Attachment is shown when navigating through attachments #58912
but when the ReportAttachmentsContext context value is not initialized isAttachmentHidden will return undefined which is falsey and isHidden will be false.
What changes do you think we should make in order to solve the problem?
Whenever the context value is no set we should fallback isHIdden to hasBeenFlagged
this will result the attachment to be visible if the user has revealed the message from the report screen but if we want to always start flagged attachments as hidden in attachment modal we can initialize the state to item.hasBeenFlagged and in that case we will not need the context.
In addition to that, currently this use effect is running without a change in current report id so it is unnecessarily resetting the context when opening the attachment modal because currentReportID object is changing
so we need to change the dependency to currentReportID?.currentReportID
NOTE:
Currently we are only updating the ReportAttachmentsContext value only from PureReportActionItem here but we have got hide/show message buttons from attachment modal too so if we want to have hidden context state shared between PureReportActionItem and carousel item and get updated both sides case we need to do a couple of things.
Update the hiddenAttachments ref to a state so that it will re-render on change so update ReportAttachmentsProvider to
const [hiddenAttachments, setHiddenAttachments] = useState<Record<string, boolean>>({});
useEffect(() => {
// We only want to store the attachment visibility for the current report.
// If the current report ID changes, clear the ref.
setHiddenAttachments({});
}, [currentReportID?.currentReportID]);
const contextValue = useMemo(
() => ({
isAttachmentHidden: (reportActionID: string) => hiddenAttachments[reportActionID],
updateHiddenAttachments: (reportActionID: string, value: boolean) => {
setHiddenAttachments({
...hiddenAttachments,
[reportActionID]: value,
});
},
}),
[hiddenAttachments],
);
Then inside PureReportActionItem add an effect that updates isHidden state if the context value updates
changed the title [-]Chat - Hidden Attachment is shown when navigating through attachments[/-][+][$250] Chat - Hidden Attachment is shown when navigating through attachments[/+]on Mar 25, 2025
changed the title [-][$250] Chat - Hidden Attachment is shown when navigating through attachments[/-][+][Due for payment 2025-04-16] [$250] Chat - Hidden Attachment is shown when navigating through attachments[/+]on Apr 9, 2025
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.24-10 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@fedirjh@kadiealexander@fedirjh The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
N/A , we have a regression test in the OP.
Regression Test Proposal Template
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Activity
melvin-bot commentedon Mar 21, 2025
Triggered auto assignment to @kadiealexander (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.FitseTLT commentedon Mar 21, 2025
🚨 Edited by proposal-police: This proposal was edited at 2025-03-21 15:26:41 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Open
Chat - Hidden Attachment is shown when navigating through attachments
What is the root cause of that problem?
We are currently trying to intialize hidden state via
isAttachmentHiddenfrom the context hereApp/src/components/Attachments/AttachmentCarousel/CarouselItem.tsx
Line 37 in 67ea2f7
but when the
ReportAttachmentsContextcontext value is not initialized isAttachmentHidden will return undefined which is falsey and isHidden will be false.What changes do you think we should make in order to solve the problem?
Whenever the context value is no set we should fallback isHIdden to hasBeenFlagged
this will result the attachment to be visible if the user has revealed the message from the report screen but if we want to always start flagged attachments as hidden in attachment modal we can initialize the state to
item.hasBeenFlaggedand in that case we will not need the context.In addition to that, currently this use effect is running without a change in current report id so it is unnecessarily resetting the context when opening the attachment modal because
currentReportIDobject is changingApp/src/pages/home/report/ReportAttachmentsContext.tsx
Line 23 in 67ea2f7
so we need to change the dependency to
currentReportID?.currentReportIDNOTE:
Currently we are only updating the ReportAttachmentsContext value only from PureReportActionItem here but we have got hide/show message buttons from attachment modal too so if we want to have hidden context state shared between PureReportActionItem and carousel item and get updated both sides case we need to do a couple of things.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
We can render AttachmentModal with a flagged attachment and add a test ID to hide button here and assert that it has a text of reveal message.
What alternative solutions did you explore? (Optional)
melvin-bot commentedon Mar 25, 2025
Job added to Upwork: https://www.upwork.com/jobs/~021904422893400846619
[-]Chat - Hidden Attachment is shown when navigating through attachments[/-][+][$250] Chat - Hidden Attachment is shown when navigating through attachments[/+]melvin-bot commentedon Mar 25, 2025
Triggered auto assignment to Contributor-plus team member for initial proposal review - @fedirjh (
External)22 remaining items
[-][$250] Chat - Hidden Attachment is shown when navigating through attachments[/-][+][Due for payment 2025-04-16] [$250] Chat - Hidden Attachment is shown when navigating through attachments[/+]melvin-bot commentedon Apr 9, 2025
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Apr 9, 2025
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.24-10 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2025-04-16. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Apr 9, 2025
@fedirjh @kadiealexander @fedirjh The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
kadiealexander commentedon Apr 16, 2025
Payments needed:
@fedirjh please complete the checklist!
jliexpensify commentedon Apr 18, 2025
Adding myself as B0 to help as Kadie is OOO for the next week.
Bump @fedirjh for the checklist!
fedirjh commentedon Apr 18, 2025
BugZero Checklist:
Bug classification
Source of bug:
Where bug was reported:
Who reported the bug:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: [TS migration] Migrate AttachmentCarousel to typescript #36658 (comment)
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
N/A , we have a regression test in the OP.
Regression Test Proposal Template
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎
jliexpensify commentedon Apr 20, 2025
Awesome, cheers @fedirjh - here is the payment summary
Closing!
garrettmknight commentedon Apr 22, 2025
$250 approved for @fedirjh