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
[HOLD for payment 2024-10-14] [$250] mWeb - Attachment - Opened offline attachment directed to conversation page on online #48173
Version Number: 9.0.25 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Issue reported by: Applause - Internal Team
Please restate the problem we are trying to solve with this issue.
mWeb - Attachment - Opened offline attachment directed to conversation page on online.
What is the root cause of this problem?
When we are offline, we upload an attachment and click on it to view the details by clicking the attachment. When we return online, we invoke submitAndClose function because an attachment has been sent. Inside this function, we close the modal with setIsModalOpen(false) after sending the attachment.
What changes do you think we should make in order to solve the problem?
We can add a new parameter to the URL or a parameter inside the function to indicate how the AttachmentModal was opened. For example, we can use ?openType=openDetail when the user opens the attachment by clicking on it, and ?openType=submit when the user submits the attachment. We can then conditionally close the modal based on the value of openType.
What alternative solutions did you explore? (Optional)
We can check if there is existing Onyx data for the attachment. If there is, it means the attachment has been submitted but not yet added to the backend. In this case, we can avoid invoking setIsModalOpen(false) and keep the modal open.
Edited by proposal-police: This proposal was edited at 2024-08-28 14:38:24 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When opening a sent attachment while offline, after going online, the app navigates to a report.
What is the root cause of that problem?
When viewing an attachment image, the AttachmentCarousel is displayed. It uses logic to determine if the viewed image has been deleted then dismiss the modal. This is done by comparing the source (a URL parameter) with the available attachment properties in reportActions:
The lines detects if the viewed image is deleted by comparing the current source with the updated attachment properties retrieved from reportActions.
When the user is offline, the current source is a blob URL string. When the user goes online, this source is updated to a new path.
The current detection logic mistakenly identifies the image as deleted because the blob URL is no longer available, resulting in the dismissal of the modal.
What changes do you think we should make in order to solve the problem?
We could add a check in the if clause to determine whether the current source is an image that will be uploaded, by verifying if the source starts with blob and if the new attachment has the same file name as the uploaded image.
The revised code could look like this, assuming a report action can have multiple images (i.e., an array):
if(initialPage===-1&&attachments.find(compareImage)){letisUploadedImage=false;// maybe cheching for wheter the file is blob uri object is enough, but for more code completeness I am adding additional checks.// If we want to checks whether the blob uri object exist we can use `FileUtils.readFileAsync`if(source.startsWith('blob')){constuploadedAttachment=attachments.find(compareImage);constpossibleTargetUploads=targetAttachments.filter(attachment=>{returnattachment.reportActionID===uploadedAttachment.reportActionID;});isUploadedImage=possibleTargetUploads.some(attachment=>{returnattachment.file.name===uploadedAttachment.file.name;});}if(!isUploadedImage){Navigation.dismissModal();}}
Alternatively, we could check for pending actions such as deletion or addition, if this approach is more accurate, or simply verify whether the reportAction is a deleted message.
What alternative solutions did you explore? (1)
We can determine whether the report action has been deleted by checking the availability of currently viewed report attahcment's reportActionID in targetAttachment. Then set the search result to initialPage.
letinitialPage=targetAttachments.findIndex(compareImage);constcurrentAttachmentReportActionID=attachments.find(compareImage)?.reportActionID;constisReportActionExist=currentAttachmentReportActionID ? targetAttachments.find(attachment=>attachment.reportActionID===currentAttachmentReportActionID) : initialPage!==-1;// Dismiss the modal when deleting an attachment during its display in preview.if(initialPage===-1&&attachments.find(compareImage)){if(!isReportActionExist){Navigation.dismissModal();}}
What alternative solutions did you explore? (2)
Expanding my first solution which I mention to use pendingAction data:
We could add pendingAction data to the attachment. If the report action for the currently viewed attachment is pendingAction add, we should not dismiss the modal.
This is a simplified version of my initial solution to determine whether a file is stored temporarily by the browser or app. We can check if the source starts with "blob" or "file," or similar characters that indicate it is a file stored in user storage. The code could be:
In this logic, we check if the currently open attachment (identified by the source prop) was present in the previous list of attachments (identified by the attachments state) but no longer appears in the updated list (identified by the targetAttachments variable). If this condition is met, we call Navigation.dismissModal() to close the modal.
When we upload an image while offline and then reconnect online, the attachment source data switches from a blob value to the value returned by the backend, triggering the condition mentioned above to be true.
What changes do you think we should make in order to solve the problem?
Since the scenario "User A is viewing an attachment and then it gets deleted by User B" only occurs with attachments that are not local files, we only need to update the condition accordingly:
changed the title [-]mWeb - Attachment - Opened offline attachment directed to conversation page on online[/-][+][$250] mWeb - Attachment - Opened offline attachment directed to conversation page on online[/+]on Aug 30, 2024
changed the title [-][$250] mWeb - Attachment - Opened offline attachment directed to conversation page on online[/-][+][HOLD for payment 2024-10-14] [$250] mWeb - Attachment - Opened offline attachment directed to conversation page on online[/+]on Oct 7, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.45-4 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
[@s77rt] The PR that introduced the bug has been identified. Link to the PR:
[@s77rt] 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:
[@s77rt] A discussion in #expensify-bugs 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:
[@s77rt] Determine if we should create a regression test for this bug.
[@s77rt] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
[@mallenexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
Activity
melvin-bot commentedon Aug 28, 2024
Triggered auto assignment to @kevinksullivan (
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.NJ-2020 commentedon Aug 28, 2024
Proposal
Please restate the problem we are trying to solve with this issue.
mWeb - Attachment - Opened offline attachment directed to conversation page on online.
What is the root cause of this problem?
When we are offline, we upload an attachment and click on it to view the details by clicking the attachment. When we return online, we invoke
submitAndClosefunction because an attachment has been sent. Inside this function, we close the modal withsetIsModalOpen(false)after sending the attachment.App/src/components/AttachmentModal.tsx
Lines 257 to 273 in 6697c26
What changes do you think we should make in order to solve the problem?
We can add a new parameter to the URL or a parameter inside the function to indicate how the AttachmentModal was opened. For example, we can use
?openType=openDetailwhen the user opens the attachment by clicking on it, and?openType=submitwhen the user submits the attachment. We can then conditionally close the modal based on the value of openType.What alternative solutions did you explore? (Optional)
We can check if there is existing Onyx data for the attachment. If there is, it means the attachment has been submitted but not yet added to the backend. In this case, we can avoid invoking setIsModalOpen(false) and keep the modal open.
NJ-2020 commentedon Aug 28, 2024
Proposal
Updated
tsa321 commentedon Aug 28, 2024
Edited by proposal-police: This proposal was edited at 2024-08-28 14:38:24 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When opening a sent attachment while offline, after going online, the app navigates to a report.
What is the root cause of that problem?
When viewing an attachment image, the
AttachmentCarouselis displayed. It uses logic to determine if the viewed image has been deleted then dismiss the modal. This is done by comparing thesource(a URL parameter) with the available attachment properties inreportActions:App/src/components/Attachments/AttachmentCarousel/index.tsx
Lines 91 to 94 in 6697c26
The lines detects if the viewed image is deleted by comparing the current source with the updated attachment properties retrieved from
reportActions.When the user is offline, the current source is a
blobURL string. When the user goes online, this source is updated to a new path.The current detection logic mistakenly identifies the image as deleted because the
blobURL is no longer available, resulting in the dismissal of the modal.What changes do you think we should make in order to solve the problem?
We could add a check in the
ifclause to determine whether the current source is an image that will be uploaded, by verifying if the source starts withbloband if the new attachment has the same file name as the uploaded image.The revised code could look like this, assuming a report action can have multiple images (i.e., an array):
Alternatively, we could check for pending actions such as deletion or addition, if this approach is more accurate, or simply verify whether the
reportActionis a deleted message.What alternative solutions did you explore? (1)
We can determine whether the report action has been deleted by checking the availability of currently viewed report attahcment's reportActionID in
targetAttachment. Then set the search result to initialPage.The code could be:
Or :
What alternative solutions did you explore? (2)
Expanding my first solution which I mention to use pendingAction data:
We could add
pendingActiondata to the attachment. If the report action for the currently viewed attachment ispendingAction add, we should not dismiss the modal.In this line:
App/src/components/Attachments/AttachmentCarousel/extractAttachments.ts
Line 104 in fc849dd
We need to modify it to:
(Additionally, some modifications to the
replacefunction are based on the bug I mentioned at the bottom of my proposal):Then, in this line and this line, we should add:
In the
AttachmentCarousel, we modify the lines near the dismiss modal to:What alternative solutions did you explore? (3)
This is a simplified version of my initial solution to determine whether a file is stored temporarily by the browser or app. We can check if the source starts with "blob" or "file," or similar characters that indicate it is a file stored in user storage. The code could be:
Also there is a bug in when user send a text with image attachment, the reportActionID data will be undefined. This in because:
App/src/components/Attachments/AttachmentCarousel/extractAttachments.ts
Line 104 in 117b961
If user send a text comment and an image, there is
<br />tag and the end tag of br that will be replaced. the more correct code could be:To also fix for video:
daledah commentedon Aug 29, 2024
Edited by proposal-police: This proposal was edited at 2024-08-29 02:10:22 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Upload and open attachment in offline, then going online user directed to conversation page
What is the root cause of that problem?
We have logic to close the attachment modal if User A is viewing an attachment and it gets deleted by User B:
App/src/components/Attachments/AttachmentCarousel/index.tsx
Lines 91 to 93 in 6697c26
In this logic, we check if the currently open attachment (identified by the
sourceprop) was present in the previous list of attachments (identified by theattachmentsstate) but no longer appears in the updated list (identified by thetargetAttachmentsvariable). If this condition is met, we callNavigation.dismissModal()to close the modal.When we upload an image while offline and then reconnect online, the attachment source data switches from a blob value to the value returned by the backend, triggering the condition mentioned above to be true.
What changes do you think we should make in order to solve the problem?
App/src/components/Attachments/AttachmentCarousel/index.tsx
Line 93 in 6697c26
The same should be applied to native file.
Beside of using
isLocalFile, we can make use ofattribs[CONST.ATTACHMENT_OPTIMISTIC_SOURCE_ATTRIBUTE]by returning it in:App/src/components/Attachments/AttachmentCarousel/extractAttachments.ts
Line 76 in fc849dd
then we will use that data instead of the
isLocalFileabove to check if the attachment is local file or not. The similar logic is used in here:App/src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Line 572 in fc849dd
What alternative solutions did you explore? (Optional)
daledah commentedon Aug 29, 2024
Proposal updated
melvin-bot commentedon Aug 30, 2024
Job added to Upwork: https://www.upwork.com/jobs/~01e366edd029d4e402
[-]mWeb - Attachment - Opened offline attachment directed to conversation page on online[/-][+][$250] mWeb - Attachment - Opened offline attachment directed to conversation page on online[/+]95 remaining items
melvin-bot commentedon Oct 7, 2024
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.
If a regression has occurred and you are the assigned CM follow the instructions here.
If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.
[-][$250] mWeb - Attachment - Opened offline attachment directed to conversation page on online[/-][+][HOLD for payment 2024-10-14] [$250] mWeb - Attachment - Opened offline attachment directed to conversation page on online[/+]melvin-bot commentedon Oct 7, 2024
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Oct 7, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.45-4 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 2024-10-14. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Oct 7, 2024
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
s77rt commentedon Oct 11, 2024
mallenexpensify commentedon Oct 14, 2024
Contributor: @wildan-m paid $250 via Upwork
Contributor+: @s77rt due $250 via NewDot
I posted in the other issue to state we need a regression test there
#50296 (comment)
Thx!
JmillsExpensify commentedon Oct 14, 2024
$250 approved for @s77rt