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-07-05] [$1000] The title of thread in LHN still be attachment after deleting this attachment #20580

Closed
6 tasks done
kbecciv opened this issue Jun 12, 2023 · 50 comments
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

@kbecciv
Copy link

kbecciv commented Jun 12, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Go to any chat
  2. Send an attachment
  3. Reply in the above attachment
  4. Observe that new reply chat is created in LHN with title [Attachment]
  5. Delete above attachment

Expected Result:

Title in LHN still be [Deleted message]

Actual Result:

Title in LHN still be [Attachment]

Workaround:

Unknown

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: n/a

Reproducible in staging?: n/a

Reproducible in production?: n/a

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

Screen.Recording.2023-05-27.at.21.55.46.mov

Expensify/Expensify Issue URL:

Issue reported by: @dukenv0307

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1685199666223399

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01385d7c536631fa3d
  • Upwork Job ID: 1671638587937628160
  • Last Price Increase: 2023-06-21
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 12, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 12, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jun 12, 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

@kbecciv
Copy link
Author

kbecciv commented Jun 12, 2023

Proposal

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

The title of thread in LHN still be attachment after deleting this attachment

What is the root cause of that problem?

App/src/libs/ReportUtils.js

Lines 1112 to 1118 in 414dc10

const isAttachment = _.has(parentReportAction, 'isAttachment') ? parentReportAction.isAttachment : isReportMessageAttachment(_.last(lodashGet(parentReportAction, 'message', [{}])));
if (isAttachment) {
return `[${Localize.translateLocal('common.attachment')}]`;
}
const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'text'], '').replace(/(\r\n|\n|\r)/gm, ' ');
return parentReportActionMessage || Localize.translateLocal('parentReportAction.deletedMessage');
}

If the parent report action is attachment, we will return [Attachment] text immediately

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

We should add a condition to check if this attachment been deleted or not

const isDelete = lodashGet(parentReportAction, [‘message’, 0, ‘isDeletedParentAction’], false);

and add into the if statement like this

  if (isAttachment && !isDelete) {
            return `[${Localize.translateLocal(‘common.attachment’)}]`;
  }

What alternative solutions did you explore? (Optional)

@dukenv0307
Copy link
Contributor

dukenv0307 commented Jun 12, 2023

I can't edit my original proposal. So I Post new comment to give an alternative solution

What alternative solutions did you explore? (Optional)

Because parentReportActionMessage will be '' if the attachment is deleted so we also use parentReportActionMessage to check if this attachment is deleted or not like this

const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'text'], '').replace(/(\r\n|\n|\r)/gm, ' ');
if (isAttachment && parentReportActionMessage) {
            return `[${Localize.translateLocal('common.attachment')}]`;
}

Result

Both proposal work well

Screen.Recording.2023-06-12.at.19.13.16.mov

@bernhardoj
Copy link
Contributor

Proposal

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

The thread title in LHN does not change to Deleted Message when the parent action of attachment is deleted.

What is the root cause of that problem?

The title in LHN comes from ReportUtils.getReportName.

const reportName = ReportUtils.getReportName(report);
result.text = reportName;

If it's a thread and it's an attachment, we will always return [Attachment].

App/src/libs/ReportUtils.js

Lines 972 to 984 in 0a471b0

if (isThread(report)) {
const parentReportAction = ReportActionsUtils.getParentReportAction(report);
if (ReportActionsUtils.isTransactionThread(parentReportAction)) {
return getTransactionReportName(parentReportAction);
}
const isAttachment = _.has(parentReportAction, 'isAttachment') ? parentReportAction.isAttachment : isReportMessageAttachment(_.last(lodashGet(parentReportAction, 'message', [{}])));
if (isAttachment) {
return `[${Localize.translateLocal('common.attachment')}]`;
}
const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'text'], '').replace(/(\r\n|\n|\r)/gm, ' ');
return parentReportActionMessage || Localize.translateLocal('parentReportAction.deletedMessage');
}

Notice that we are checking 2 things to detect whether this action is an attachment or not.

  1. Check if the action has isAttachment property and return that
  2. Else, use isReportMessageAttachment. This will check the action message text and html.

When we delete an action, both html and text of a message becomes an empty string.

const deletedMessage = [
{
type: 'COMMENT',
html: '',
text: '',
isEdited: true,
isDeletedParentAction: true,
},
];

This means, the 2nd check above will return false, but the first check still returns true because isAttachment is never updated when we delete an action.

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

First of all, isAttachment attribute is just a local attribute. This means that this attribute never exist in BE, so when we reload/relogin, you won't be able to find isAttachment anymore. So, I think the better thing to do is to not rely on isAttachment and just simply use isReportMessageAttachment like we did in a few places here:

if (ReportUtils.isReportMessageAttachment({text: report.lastMessageText, html: report.lastMessageHtml})) {
lastMessageTextFromReport = `[${Localize.translateLocal('common.attachment')}]`;
} else {
lastMessageTextFromReport = report ? report.lastMessageText || '' : '';
}

if (ReportUtils.isReportMessageAttachment({text: report.lastMessageText, html: report.lastMessageHtml})) {
lastMessageTextFromReport = `[${Localize.translateLocal('common.attachment')}]`;
} else {
lastMessageTextFromReport = report ? report.lastMessageText || '' : '';
}

What alternative solutions did you explore? (Optional)

Update isAttachment to false when delete an action.

@melvin-bot melvin-bot bot added the Overdue label Jun 14, 2023
@alexpensify
Copy link
Contributor

This one is on my review list

@melvin-bot melvin-bot bot removed the Overdue label Jun 14, 2023
@alexpensify
Copy link
Contributor

I'm able to replicate it, now checking if this one is being worked on in another GH.

image

@alexpensify
Copy link
Contributor

@rushatgabhane and @tylerkaraszewski - this one seems pretty similar to the GH you are assigned here:

(#19913)

Should we consolidate this GH into the one above?

@alexpensify
Copy link
Contributor

No update

@melvin-bot melvin-bot bot added the Overdue label Jun 20, 2023
@alexpensify
Copy link
Contributor

alexpensify commented Jun 20, 2023

Tomorrow, I'll start a discussion to identify if we believe that this one is similar with #19913

@melvin-bot melvin-bot bot removed the Overdue label Jun 20, 2023
@rushatgabhane
Copy link
Member

@alexpensify this is a different issue I think. It's related to threads + deleting a message.

@alexpensify alexpensify added the External Added to denote the issue can be worked on by a contributor label Jun 21, 2023
@melvin-bot melvin-bot bot changed the title The title of thread in LHN still be attachment after deleting this attachment [$1000] The title of thread in LHN still be attachment after deleting this attachment Jun 21, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 21, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01385d7c536631fa3d

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

melvin-bot bot commented Jun 21, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jun 21, 2023

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

@alexpensify
Copy link
Contributor

Thank you @rushatgabhane for confirming this one is different. I've assigned the External label to start accepting proposals here.

@offroader
Copy link

Proposal

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

When the message is attachment and you reply in thread, title of the thread in LHN is [Attachment]. After deleting the attachment thread title should be changed to [Deleted message]. At the moment it stays unchanged.

What is the root cause of that problem?

Problem is in getReportName function, where correct logic is implemented only for regular messages, not for attachments.

App/src/libs/ReportUtils.js

Lines 1003 to 1008 in 2b2f497

const isAttachment = _.has(parentReportAction, 'isAttachment') ? parentReportAction.isAttachment : isReportMessageAttachment(_.last(lodashGet(parentReportAction, 'message', [{}])));
if (isAttachment) {
return `[${Localize.translateLocal('common.attachment')}]`;
}
const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'text'], '').replace(/(\r\n|\n|\r)/gm, ' ');
return parentReportActionMessage || Localize.translateLocal('parentReportAction.deletedMessage');

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

We should check if the message is deleted before checking it is attachment and return appropriate value.

        const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'text'], '').replace(/(\r\n|\n|\r)/gm, ' ');
        if (parentReportActionMessage) {
            const isAttachment = _.has(parentReportAction, 'isAttachment') ? parentReportAction.isAttachment : isReportMessageAttachment(_.last(lodashGet(parentReportAction, 'message', [{}])));
            return isAttachment ? `[${Localize.translateLocal('common.attachment')}]` : parentReportActionMessage;
        }
        return Localize.translateLocal('parentReportAction.deletedMessage');

In addition, we will avoid unnecessary check on being attachment (when the message is deleted) by moving that statement inside the if block.

demo.mp4

@melvin-bot
Copy link

melvin-bot bot commented Jun 22, 2023

📣 @offroader! 📣
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>

@offroader
Copy link

Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~012ed3f47a1ed0ab6d

@melvin-bot
Copy link

melvin-bot bot commented Jun 22, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jun 28, 2023

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

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 28, 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:

  • [@mollfpr] The PR that introduced the bug has been identified. Link to the PR:
  • [@mollfpr] 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:
  • [@mollfpr] 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:
  • [@mollfpr] Determine if we should create a regression test for this bug.
  • [@mollfpr] 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.
  • [@conorpendergrast] Link the GH issue for creating/updating the regression test once above steps have been agreed upon: https://github.com/Expensify/Expensify/issues/298631

@alexpensify
Copy link
Contributor

@dukenv0307 and @mollfpr - please apply to the job here: https://www.upwork.com/jobs/~01385d7c536631fa3d

Tomorrow, I need to make sure we are prepared for the payment period which is set for next week. Thank you!

@alexpensify alexpensify added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Jun 29, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 29, 2023

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 29, 2023
@melvin-bot

This comment was marked as duplicate.

@alexpensify
Copy link
Contributor

alexpensify commented Jun 29, 2023

Reassigning another bug team member, I'm going OOO until Monday, July 10.

Required action from the 🐛 team: Please set a reminder for July 5, we have a payment to prepare in Upwork for @dukenv0307 and @mollfpr. Heads up there is an incentive bonus: #20580 (comment) and @dukenv0307 is the issue reporter. I've not factored these into the payment but they are ready with proposals here: https://www.upwork.com/jobs/~01385d7c536631fa3d

Thank you!

@conorpendergrast
Copy link
Contributor

@alexpensify Thank you for the excellent write-up!

@conorpendergrast
Copy link
Contributor

Oh this was switch to Daily incorrectly. Switching back to Weekly as it's on payment hold

@conorpendergrast conorpendergrast added Weekly KSv2 and removed Daily KSv2 labels Jun 30, 2023
@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jul 4, 2023
@mollfpr
Copy link
Contributor

mollfpr commented Jul 6, 2023

I'm running out of time, will complete the checklist in the morning.

@mollfpr
Copy link
Contributor

mollfpr commented Jul 7, 2023

[@mollfpr] The PR that introduced the bug has been identified. Link to the PR:

#19517

[@mollfpr] 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:

#19517 (comment)

[@mollfpr] 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:

The regression step is enough.

[@mollfpr] Determine if we should create a regression test for this bug.
[@mollfpr] 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.

  1. Go to any chat
  2. Send an attachment
  3. Reply in the above attachment
  4. Observe that a new reply chat is created in LHN with the title [Attachment]
  5. Delete the above attachment
  6. Verify that the title in LHN still be [Deleted message]
  7. Change the language to Spanish
  8. Verify that the title [Deleted Message] is translated
  9. 👍 or 👎

@melvin-bot melvin-bot bot added the Overdue label Jul 10, 2023
@conorpendergrast
Copy link
Contributor

Offers sent to @mollfpr (with urgency bonus) and @dukenv0307 (with bug bounty and urgency bonus) via Upwork

@melvin-bot melvin-bot bot removed the Overdue label Jul 10, 2023
@conorpendergrast
Copy link
Contributor

@mollfpr paid.

Regression test created: https://github.com/Expensify/Expensify/issues/298631

@alexpensify
Copy link
Contributor

alexpensify commented Jul 10, 2023

@conorpendergrast - I'm back online and see that this is our current state:

I appreciate your help! It looks like everyone has been paid out. Are we good to close this GH or is there any required action that I need to take here?

@conorpendergrast
Copy link
Contributor

Nope, @dukenv0307 hasn't been paid yet. Looks like contract has been accepted, so I'll pay that, mark it off, and will close this

@conorpendergrast
Copy link
Contributor

And we're all done

@alexpensify
Copy link
Contributor

Perfect, thank you!

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

9 participants