Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOLD for payment 2023-06-12] [$1000] Console error on clicking on download icon on deleted message #19413

Closed
1 of 6 tasks
kavimuru opened this issue May 22, 2023 · 51 comments
Closed
1 of 6 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kavimuru
Copy link

kavimuru commented May 22, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Go to staging dot on web chrome
  2. Open console
  3. Send an image in a chat.
  4. Click reply in the image to open a thread.
  5. Delete the image while in the thread. Wait until the image deletes.
  6. Hover over the deleted message and you can see the download option
  7. Click on it and notice that nothing happens, and you see an error in the console.

Expected Result:

We shouldn't show download option after deleting a message.

Actual Result:

We show option to download the image after the image is deleted.

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.16.7
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

error-2023-05-19_15.23.30.mp4
Recording.720.mp4

Expensify/Expensify Issue URL:
Issue reported by: @priya-zha
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1684489220942129

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01f8f88bf5b41b887d
  • Upwork Job ID: 1661110256348393472
  • Last Price Increase: 2023-05-23
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 22, 2023

Triggered auto assignment to @joekaufmanexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented May 22, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@bogoroh
Copy link
Contributor

bogoroh commented May 23, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

When deleting an attachment there download button is still present which causes console.log errors.

What is the root cause of that problem?

ContextMenuActions.js has logic on if it should display the download button yes or no. The logic doesn't check if the attachment is still present. So a deleted attachment will still return true.

shouldShow: (type, reportAction) => {
            const message = _.last(lodashGet(reportAction, 'message', [{}]));
            const isAttachment = _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : ReportUtils.isReportMessageAttachment(message);
            return isAttachment && reportAction.reportActionID && false;
        },

What changes do you think we should make in order to solve the problem?

Add some additional code checks to make sure the parentAction was actually removed.

return isAttachment && reportAction.reportActionID;

Should become :
return isAttachment && reportAction.reportActionID && !reportAction.originalMessage.isDeletedParentAction;

Screenshot 2023-05-22 at 8 10 01 PM

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@melvin-bot
Copy link

melvin-bot bot commented May 23, 2023

📣 @bogoroh! 📣
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:

  1. 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.
  2. 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.
  3. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@bogoroh
Copy link
Contributor

bogoroh commented May 23, 2023

Contributor details
Your Expensify account email: mrtedits@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01043555e50efb5444

@melvin-bot
Copy link

melvin-bot bot commented May 23, 2023

⚠️ Missing/invalid email or upwork profile link. Please make sure you add both your Expensify email and Upwork profile link in the format specified.

@bogoroh
Copy link
Contributor

bogoroh commented May 23, 2023

Contributor details
Your Expensify account email: mrtedits@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01043555e50efb5444

@melvin-bot
Copy link

melvin-bot bot commented May 23, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@Pujan92
Copy link
Contributor

Pujan92 commented May 23, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Console error on trying to download the deleted attachment

What is the root cause of that problem?

On deleting the attachment we are cleaning the html prop of the message and on click of the delete it should throw an error here bcoz the sourceURL will be null here. So accessing the match on null will cause the issue.

const message = _.last(lodashGet(reportAction, 'message', [{}]));
const html = lodashGet(message, 'html', '');
const attachmentDetails = getAttachmentDetails(html);
const {originalFileName, sourceURL} = attachmentDetails;
const sourceURLWithAuth = addEncryptedAuthTokenToURL(sourceURL);
const sourceID = (sourceURL.match(CONST.REGEX.ATTACHMENT_ID) || [])[1];

What changes do you think we should make in order to solve the problem?

We should not show the delete option in the context actions as the image url is being removed from the html prop of the message. To achieve this we need to add 1 more condition && !message.isDeletedParentAction here.

return isAttachment && reportAction.reportActionID;

Screenshot 2023-05-23 at 7 51 11 AM

@hungvu193
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

Console error on clicking on download icon on deleted message

What is the root cause of that problem?

When we deleted the attachment thread message, we remove the text and html. So when we tried to download the deleted attachment, it will be crashed since sourceURL will be null:

const sourceID = (sourceURL.match(CONST.REGEX.ATTACHMENT_ID) || [])[1];

What changes do you think we should make in order to solve the problem?

Since isAttachment inside reportAction isn't updated when we deleted the thread attachment message and we already had a function to check if the current message is attachment, I think we can hide the download button by updating the condition of isAttachment inside shouldShow function of Download button to this:

 const isAttachment = ReportUtils.isReportMessageAttachment(message);

// Optional: we can also update isReportMessageAttachment 
export default function isReportMessageAttachment({text, html, isDeletedParentAction}) {
    if (isDeletedParentAction || !text || !html) {
        return false;
    }

    const regex = new RegExp(` ${CONST.ATTACHMENT_SOURCE_ATTRIBUTE}="(.*)"`, 'i');
    return text === CONST.ATTACHMENT_MESSAGE_TEXT && !!html.match(regex);
}

What alternative solutions did you explore? (Optional)

We can also still allow the download button with deleted attachment, but we should add an early return and showing an error for user to let them know, this attachment is no longer exist, they can't download them:

// inside onPress function 
const {originalFileName, sourceURL} = attachmentDetails;
 if (!sourceURL) {
  Grow.show(' this attachment is no longer exist'....);
   hideContextMenu(true, ReportActionComposeFocusManager.focus);
}

@LiaKim07
Copy link

LiaKim07 commented May 23, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Console error on trying to download the deleted attachment

What is the root cause of that problem?

When click the download on deleting the attachment, sourceURL will be null value. That's why it shows console error when click the download icon.
image

What changes do you think we should make in order to solve the problem?

In fact, the tooltip part should not be shown for deleted attachments and deleted messages like Slack and other chatting apps.
We don't have any text and attachments to copy, delete or download so no need to show those icons.
image

image
I think, it's the right way in the chatting app.

We can implement that functionality based on whether the message or attachment is deleted.

@joekaufmanexpensify
Copy link
Contributor

I was able to reproduce this on web. However, the bug here isn't the console error IMO. It's that we show a download icon after deleting the image. We shouldn't show this.

Also, this doesn't just apply to workspaces. It applies to any type of message in the app. Cleaned up the reproduction steps to reflect this.

@joekaufmanexpensify joekaufmanexpensify added the External Added to denote the issue can be worked on by a contributor label May 23, 2023
@melvin-bot melvin-bot bot changed the title Console error on clicking on download icon on deleted message [$1000] Console error on clicking on download icon on deleted message May 23, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 23, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01f8f88bf5b41b887d

@melvin-bot
Copy link

melvin-bot bot commented May 23, 2023

Current assignee @joekaufmanexpensify is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented May 23, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @0xmiroslav (External)

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label May 23, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 23, 2023

Triggered auto assignment to @bondydaa (External), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@joekaufmanexpensify
Copy link
Contributor

@0xmiroslav could you please review the above proposals when you have a chance?

@0xmiros
Copy link
Contributor

0xmiros commented May 24, 2023

reviewing now

@0xmiros
Copy link
Contributor

0xmiros commented May 24, 2023

It doesn't make sense at all to show these icons since deleted attachment is not downloadable, copiable or deletable.
@bondydaa do you agree?

Screenshot 2023-05-24 at 10 29 40 PM

@melvin-bot
Copy link

melvin-bot bot commented May 25, 2023

📣 @victornnaji! 📣
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:

  1. 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.
  2. 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.
  3. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@LiaKim07
Copy link

LiaKim07 commented May 25, 2023

@0xmiroslav , and we need reactions and 'Mark as Unread' for the [Deleted Message]?

image

@0xmiros
Copy link
Contributor

0xmiros commented May 25, 2023

and we need reactions and 'Mark as Unread' for the [Deleted Message]?

I think no problem with it.
@bondydaa @joekaufmanexpensify what are your thoughts?

@melvin-bot melvin-bot bot added the Reviewing Has a PR in review label May 29, 2023
@bondydaa
Copy link
Contributor

bondydaa commented Jun 1, 2023

I merged the PR today so should get deployed soon, maybe tomorrow or next week. i haven't kept up with our deploy status this week.

@joekaufmanexpensify
Copy link
Contributor

@jliexpensify I'm back from OOO, so removing your assignment. Thanks for covering!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Jun 5, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Console error on clicking on download icon on deleted message [HOLD for payment 2023-06-12] [$1000] Console error on clicking on download icon on deleted message Jun 5, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 5, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jun 5, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 5, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.23-7 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 2023-06-12. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Jun 5, 2023

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:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 11, 2023
@joekaufmanexpensify
Copy link
Contributor

@0xmiroslav Could you please complete your steps for the C+ checklist? Then, we can issue payment here.

@0xmiros
Copy link
Contributor

0xmiros commented Jun 12, 2023

No PRs caused regression but this case was missed while implementing thread feature. I think regression test needs to be migrated into #20074 which handles all context menu actions, not only download icon.

@joekaufmanexpensify
Copy link
Contributor

I think regression test needs to be migrated into #20074 which handles all context menu actions, not only download icon.

@0xmiroslav Isn't that issue just for regular messages though? Vs this being images specifically. I agree they are related, but it feels like a slightly different case. Or do you mean just have the image case as a 1b regression test to the 1a in the above linked issue?

@0xmiros
Copy link
Contributor

0xmiros commented Jun 12, 2023

@joekaufmanexpensify that issue about parent [Deleted message] in thread. Same as this GH.

@joekaufmanexpensify
Copy link
Contributor

It's not the same exact case though, no? Since this issue is specifically with images and the download button. And that one seems to be just text messages generally, and then other buttons on the clipboard menu. But LMK if that's not correct!

@0xmiros
Copy link
Contributor

0xmiros commented Jun 12, 2023

So comprehensive regression test step will be:

  1. Send any message (or any attachment) in any chat room
  2. Thread that message
  3. Send any message on that thread
  4. Delete parent message
  5. Hover [Deleted message]
  6. Verify that context menu shows only "Mark as unread" icon, no other icons show

@joekaufmanexpensify
Copy link
Contributor

@bogoroh was assigned to this issue on May 29th at 10:49am ET. The PR was merged on June 1st at 12:50pm ET. This is slightly longer than 72 hours. However, @0xmiroslav approved the PR's changes on May 30th (which was considerably less than 72 hours.) We then approved the PR and merged it (without requesting any other changes).

@bondydaa and I chatted, and since the delay that pushed this past the 72 hour mark was internal, this still qualifies for a speed bonus. So we need to issue these payments:

  • @bogoroh $1,500 for PR.
  • @0xmiroslav $1,500 for C+ review.
  • @priya-zha $250 for reporting.

@joekaufmanexpensify
Copy link
Contributor

joekaufmanexpensify commented Jun 12, 2023

So comprehensive regression test step will be:

Cool those steps makes sense. I commented them on the other issue to save them the work: #20074 (comment)

@joekaufmanexpensify
Copy link
Contributor

BZ checklist is complete, all set to issue payment here!

@joekaufmanexpensify
Copy link
Contributor

@bogoroh $1,500 sent and contract ended!

@joekaufmanexpensify
Copy link
Contributor

@priya-zha $250 sent and contract ended!

@joekaufmanexpensify
Copy link
Contributor

@0xmiroslav $1,500 sent and contract ended!

@joekaufmanexpensify
Copy link
Contributor

Upwork job closed.

@joekaufmanexpensify
Copy link
Contributor

Bug is fixed, BZ checklist complete, and all payment issued. Closing as this is all set. Thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

10 participants