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-08-17] [$1000] Red dot and [Attachment] shows in LHN even after close error message #24136

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

Comments

@kavimuru
Copy link

kavimuru commented Aug 3, 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 any chat
  2. send any corrupted file
  3. click on X button in Unexpected error message

Expected Result:

should not show red dot and [Attachment] in LHN

Actual Result:

red dot and [Attachment] shows in LHN

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.50-0
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

Screen.Recording.2023-08-01.at.2.08.17.PM.mov
Recording.1441.mp4

Expensify/Expensify Issue URL:
Issue reported by: @gadhiyamanan
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1690879133508289

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~019aca46aa1b2b9812
  • Upwork Job ID: 1687588216647823360
  • Last Price Increase: 2023-08-04
  • Automatic offers:
    • gadhiyamanan | Reporter | 25956660
    • bernhardoj | Contributor | 25986609
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 3, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 3, 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

@kavimuru kavimuru changed the title Red dot and [Attachment] shows in LHN even after close error message shows in LHN even after close error message From: @Manan Gadhiya Red dot and [Attachment] shows in LHN even after close error message shows in LHN even after close error message Aug 3, 2023
@kavimuru kavimuru changed the title Red dot and [Attachment] shows in LHN even after close error message shows in LHN even after close error message Red dot and [Attachment] shows in LHN even after close error message Aug 3, 2023
@c3024
Copy link
Contributor

c3024 commented Aug 4, 2023

Proposal

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

On closing the error in reportAction the red dot is not removed and last message is not updated in LHN.

What is the root cause of that problem?

This here

onClose={() => ReportActions.clearReportActionErrors(props.report.reportID, props.action)}

is handler on clicking close on the error.
This method here deletes this attachment report action on clicking the close on attachment uploading error.
function clearReportActionErrors(reportID, reportAction) {

but it does not update the report's lastMessageText, actor, translation key etc.

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

We should update the report also here when we click close on the error similar to the deleteReportComment

onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${originalReportID}`,
value: optimisticReport,
},

So, we replace this
// Delete the optimistic action
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {
[reportAction.reportActionID]: null,
});

with something like this

const optimisticReportActions = {
            [reportAction.reportActionID]: null,
        };
        // Delete the optimistic action
        Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {
            ...optimisticReportActions,
        });
        let optimisticReport = {
            lastMessageTranslationKey: '',
            lastMessageText: '',
            lastVisibleActionCreated: '',
        };
        const {lastMessageText = '', lastMessageTranslationKey = ''} = ReportActionUtils.getLastVisibleMessage(reportID, optimisticReportActions);
        if (lastMessageText || lastMessageTranslationKey) {
            const lastVisibleAction = ReportActionUtils.getLastVisibleAction(reportID, optimisticReportActions);
            const lastVisibleActionCreated = lastVisibleAction.created;
            const lastActorAccountID = lastVisibleAction.actorAccountID;
            optimisticReport = {
                lastMessageTranslationKey,
                lastMessageText,
                lastVisibleActionCreated,
                lastActorAccountID,
            };
        }
        Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, optimisticReport);

Since we are reusing the same logic we might extract this to a separate function in Report or ReportUtils

What alternative solutions did you explore? (Optional)

@jeet-dhandha
Copy link
Contributor

Proposal

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

  • We have two issues here:
    • [Issue 1] - Red dot is still showing in LHN even after we close the error message.
    • [Issue 2] - [Attachment] text shows in LHN even after we close error message.

What is the root cause of that problem?

  • [Issue 1] - In OptionsRowLHNData.js below line doesn't get any effect (as we are accessing reportActions directly from onyx listener in SidebarUtils.js) when clearing errors and thus its not updating the Red Dot.

const item = SidebarUtils.getOptionData(fullReport, personalDetails, preferredLocale, policy);

  • [Issue 2] - When API fails to upload attachment it should revert last message to given lastMessageText but it isn't doing that.

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

  • [Issue 1] - We should add a reportActions key to withOnyx HOC and then we can pass it to the useMemo dependency array. This will update the Red Dot when we clear the error.
reportActions: {
    key: (props) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${props.reportID}`,
    canEvict: false, // I still don't know what this is used for but I had to pass it to make it run.
},
  • [Issue 2] - On backend we should revert last message to given lastMessageText when API fails to upload attachment.

What alternative solutions did you explore? (Optional)

  • N/A

@bernhardoj
Copy link
Contributor

Proposal

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

Clearing the error message does not update the last message text.

What is the root cause of that problem?

The real issue here is that, when the attachment upload is failed, we should revert the last message text to the previous text. This issue was previously fixed here #22342, but a new report attribute called lastMessageTranslationKey is introduced.

When we upload an attachment, lastMessageTranslationKey will be optimistically set to common.attachment.

lastMessageTranslationKey: lodashGet(lastAction, 'message[0].translationKey', ''),

translationKey: isAttachment ? CONST.TRANSLATION_KEYS.ATTACHMENT : '',

When the attachment fails to upload, we only revert the lastMessageText of the report, so lastMessageTranslationKey value is still common.attachment.

const failureReport = {
lastMessageText: prevVisibleMessageText,
};
const failureData = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: failureReport,
},

LHN last message will prioritize lastMessageTranslationKey if exist.

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

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

We should also revert the lastMessageTranslationKey. We can basically take the last message revert logic from the delete comment.

const {lastMessageText = '', lastMessageTranslationKey = ''} = ReportActionsUtils.getLastVisibleMessage(originalReportID, optimisticReportActions);
if (lastMessageText || lastMessageTranslationKey) {
const lastVisibleAction = ReportActionsUtils.getLastVisibleAction(originalReportID, optimisticReportActions);
const lastVisibleActionCreated = lastVisibleAction.created;
const lastActorAccountID = lastVisibleAction.actorAccountID;
optimisticReport = {
lastMessageTranslationKey,
lastMessageText,
lastVisibleActionCreated,
lastActorAccountID,
};
}
}

snippet
let failureReport = {
    lastMessageTranslationKey: '',
    lastMessageText: '',
    lastVisibleActionCreated: '',
};
const {lastMessageText = '', lastMessageTranslationKey = ''} = ReportActionsUtils.getLastVisibleMessage(reportID);
if (lastMessageText || lastMessageTranslationKey) {
    const lastVisibleAction = ReportActionsUtils.getLastVisibleAction(reportID);
    const lastVisibleActionCreated = lastVisibleAction.created;
    const lastActorAccountID = lastVisibleAction.actorAccountID;
    failureReport = {
        lastMessageTranslationKey,
        lastMessageText,
        lastVisibleActionCreated,
        lastActorAccountID,
    };
}

@kevinksullivan kevinksullivan added the External Added to denote the issue can be worked on by a contributor label Aug 4, 2023
@melvin-bot melvin-bot bot changed the title Red dot and [Attachment] shows in LHN even after close error message [$1000] Red dot and [Attachment] shows in LHN even after close error message Aug 4, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 4, 2023

Job added to Upwork: https://www.upwork.com/jobs/~019aca46aa1b2b9812

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

melvin-bot bot commented Aug 4, 2023

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

@kevinksullivan
Copy link
Contributor

Agree this is a bug, moving forward to external

@melvin-bot
Copy link

melvin-bot bot commented Aug 4, 2023

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

@kevinksullivan kevinksullivan added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Aug 4, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 4, 2023

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

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 4, 2023
@kevinksullivan kevinksullivan self-assigned this Aug 4, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 4, 2023

📣 @rushatgabhane Please request via NewDot manual requests for the Contributor role ($1000)

@melvin-bot
Copy link

melvin-bot bot commented Aug 4, 2023

📣 @gadhiyamanan 🎉 An offer has been automatically sent to your Upwork account for the Reporter role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@Expensify Expensify deleted a comment from melvin-bot bot Aug 4, 2023
@kevinksullivan
Copy link
Contributor

@tjferriss I am going OOO for a week, so tapping you in to help out in the interim. Thanks!

@rushatgabhane
Copy link
Member

I like @bernhardoj's proposal #24136 (comment) because it fixes the root cause

C+ reviewed 🎀 👀 🎀

@melvin-bot
Copy link

melvin-bot bot commented Aug 6, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 7, 2023

📣 @rushatgabhane Please request via NewDot manual requests for the Reviewer role ($1000)

@melvin-bot
Copy link

melvin-bot bot commented Aug 7, 2023

📣 @bernhardoj 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@bernhardoj
Copy link
Contributor

PR is ready

cc: @rushatgabhane

@melvin-bot
Copy link

melvin-bot bot commented Aug 9, 2023

🎯 ⚡️ Woah @rushatgabhane / @bernhardoj, great job pushing this forwards! ⚡️

The pull request got merged within 3 working days of assignment, so this job is eligible for a 50% #urgency bonus 🎉

  • when @bernhardoj got assigned: 2023-08-07 10:41:25 Z
  • when the PR got merged: 2023-08-09 12:36:54 UTC

On to the next one 🚀

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Aug 10, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Red dot and [Attachment] shows in LHN even after close error message [HOLD for payment 2023-08-17] [$1000] Red dot and [Attachment] shows in LHN even after close error message Aug 10, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Aug 10, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 10, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 10, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.52-5 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-08-17. 🎊

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.

For reference, here are some details about the assignees on this issue:

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 Aug 10, 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:

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

@rushatgabhane
Copy link
Member

rushatgabhane commented Aug 14, 2023

  1. The PR that introduced the bug has been identified. Link to the PR: Fix: Translation for system message #21780

  2. 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: https://github.com/Expensify/App/pull/21780/files#r1293875228

  3. 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: https://expensify.slack.com/archives/C01GTK53T8Q/p1692040783758609

  4. Determine if we should create a regression test for this bug. No. This is one off bug

  5. 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 - N.A.

@rushatgabhane
Copy link
Member

Created a manual request - https://staging.new.expensify.com/r/3716241818407301

@kevinksullivan
Copy link
Contributor

Payment summary

@kevinksullivan
Copy link
Contributor

Adding @JmillsExpensify for the newdot payment. Following this SO, but let me know if I should be doing something differently

@kevinksullivan
Copy link
Contributor

Payments made to @gadhiyamanan and @bernhardoj

@JmillsExpensify
Copy link

Reviewed the details for @rushatgabhane. Approved for $1,500 payment in NewDot based on the BZ summary above.

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. External Added to denote the issue can be worked on by a contributor Weekly KSv2
Projects
None yet
Development

No branches or pull requests

9 participants