Skip to content

[PAID] [$500] Chat - [Attachment] shows in LHN even after close error message #26047

Closed

Description

@lanitochka17

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. Send any message
  4. Delete the message
  5. Click on X button in Unexpected error message

Expected Result:

Last message should show in LHN

Actual Result:

[Attachment] shows in LHN

Workaround:

Unknown

Platforms:

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

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

Version Number: 1.3.57-5

Reproducible in staging?: Yes

Reproducible in production?: Yes

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-19.at.5.43.37.PM.1.mov

corrupt_PDF .pdf

Recording.6021.mp4

Expensify/Expensify Issue URL:

Issue reported by: @gadhiyamanan

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01aad872dd6b0a5da1
  • Upwork Job ID: 1697750932793446400
  • Last Price Increase: 2023-09-01
  • Automatic offers:
    • s77rt | Reviewer | 26485402
    • c3024 | Contributor | 26485404
    • gadhiyamanan | Reporter | 26485405

Activity

  1. added
    Daily
    Bug
    on Aug 28, 2023
  2. melvin-bot commented on Aug 28, 2023

    @melvin-bot

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

  3. melvin-bot commented on Aug 28, 2023

    @melvin-bot

    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
  4. c3024 commented on Aug 28, 2023

    @c3024
    Contributor

    Proposal

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

    Sending an invalid attachment and then sending a message and deleting it shows [Attachment] in LHN and it does not go away even on clicking close on the error

    What is the root cause of that problem?

    As long as we don't close the error the report action of failed attachment stays in the report. So when we delete the latest message, the lastVisibleAction is this failed attachment message and this being an attachment, the lastMessageTranslationKey of Report here

    const {lastMessageText = '', lastMessageTranslationKey = ''} = ReportActionsUtils.getLastVisibleMessage(originalReportID, optimisticReportActions);

    becomes [Attachment] and the LHN shows [Attachment]
    This here
    function clearReportActionErrors(reportID, reportAction) {

    gets triggered when clicking close button of the error but it makes no changes to report so the lastMessageTranslationKey stays and the [Attachment] is shown even after clicking the close.

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

    If an action has errors it should not be considered as lastVisibleAction of the report. So, we should return false for reportActions which have errors here

    function shouldReportActionBeVisibleAsLastAction(reportAction) {
    if (!reportAction) {
    return false;
    }

    by modifying the conditional to

        if (!reportAction || !_.isEmpty(reportAction.errors)) {
            return false;
        }

    then when we delete the latest message, the failed attachment report action is not considered as a valid last visible report action and the report action previous to this will be taken as the last visible report action and proper message is displayed in LHN.
    This is also in line with PR #24213 and #22342 where when the sent message fails, the lastMessageTranslationKey and lastMessageText are set to the previous values in the failureData. This is why if when the attachment sending fails, the LHN shows the previous message instead of [Attachment] because these PRs restore the lastMessageTranslationKey to previous value in failure data for report.
    But when we send another message and delete it, the lastVisibleAction is found afresh and it happens to be the failed report action and the lastMessageTranslationKey of report updates to [Attachment].

    So, the solution suggested above of checking errors of report actions prevents any report actions with errors to be last visible action.

    What alternative solutions did you explore? (Optional)

    We might continue considering the failed report action also as a valid last visible action and change the lastMessageTranslation from [Attachment] to a previous message on clicking the close button by updating the report here

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

    with 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);

    similar to deleteReportComment of Report.js
    but this behaviour would be inconsistent with the logic of PRs mentioned above.
    Because, with this approach if we send a invalid attachment and it fails, the LHN does not show[Attachment] then (case 1) but if we send another message and delete it now the LHN shows [Attachment] (case 2) because the last visible action is found freshly again. Even though case 1 and 2 are identical, the LHN shows differently. So I think the first solution to exclude report actions with errors when finding lastVisibleAction is the better solution and consistent with existing behaviour.

    Result
    updateLastVisibleActionCorrectly.mov
  5. strepanier03 commented on Aug 30, 2023

    @strepanier03
    Contributor

    Reached out internally for a discussion about this and will update tomorrow.

  6. added
    External
    on Sep 1, 2023
  7. changed the title [-]Chat - [Attachment] shows in LHN even after close error message[/-] [+][$500] Chat - [Attachment] shows in LHN even after close error message[/+] on Sep 1, 2023
  8. melvin-bot commented on Sep 1, 2023

    @melvin-bot
  9. added
    Help Wanted
    on Sep 1, 2023
  10. melvin-bot commented on Sep 1, 2023

    @melvin-bot

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

  11. melvin-bot commented on Sep 1, 2023

    @melvin-bot

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

  12. 18 remaining items

  13. added
    Weekly
    Awaiting Payment
    on Sep 6, 2023
  14. changed the title [-][$500] Chat - [Attachment] shows in LHN even after close error message[/-] [+][HOLD for payment 2023-09-13] [$500] Chat - [Attachment] shows in LHN even after close error message[/+] on Sep 6, 2023
  15. melvin-bot commented on Sep 6, 2023

    @melvin-bot

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

  16. removed
    Reviewing
    on Sep 6, 2023
  17. melvin-bot commented on Sep 6, 2023

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.64-2 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-09-13. 🎊

    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

    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
  18. melvin-bot commented on Sep 6, 2023

    @melvin-bot

    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.
    • [@strepanier03] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  19. s77rt commented on Sep 6, 2023

    @s77rt
    Member
  20. added
    Daily
    and removed
    Weekly
    on Sep 13, 2023
  21. strepanier03 commented on Sep 13, 2023

    @strepanier03
    Contributor

    @s77rt and @c3024 - I have paid you via Upwork and closed the contracts/left feedback. Thanks again!

    @gadhiyamanan - Once you accept the offer let me know here so I can pay it as well.

    Thanks!

  22. gadhiyamanan commented on Sep 14, 2023

    @gadhiyamanan
    Contributor

    @strepanier03 offer accepted but the amount of offer is $50. It is eligible for $250 because it is logged before 30 aug. Please add $200 as bonus

  23. strepanier03 commented on Sep 14, 2023

    @strepanier03
    Contributor

    @gadhiyamanan - Got it, thanks for the heads up. I've paid you out at the previous $250 price since this issue was created before the 30th of August.

    All set here now, closing out.

  24. changed the title [-][HOLD for payment 2023-09-13] [$500] Chat - [Attachment] shows in LHN even after close error message[/-] [+][PAID] [$500] Chat - [Attachment] shows in LHN even after close error message[/+] on Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions