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

[$500] Task - Deleted task gets highlighted and chat turns bold after deletion #35100

Closed
5 of 6 tasks
lanitochka17 opened this issue Jan 24, 2024 · 27 comments
Closed
5 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Jan 24, 2024

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


Version Number: 1.4.31-2
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4235875
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Open the app and log in
  2. Navigate to any chat and assign a task
  3. Open the created task
  4. Add a comment in the task conversation
  5. Delete task
  6. Navigate back to the chat and then to LHN

Expected Result:

The "Deleted task" message in not highlighted and there is no change in chat

Actual Result:

The "Deleted task" message is highlighted and the chat gets bold in LHN

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6353662_1706125398601.IMG_4702.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0179cecbe3829d643a
  • Upwork Job ID: 1750259088120512512
  • Last Price Increase: 2024-01-24
  • Automatic offers:
    • tienifr | Contributor | 0
@lanitochka17 lanitochka17 added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 24, 2024
Copy link

melvin-bot bot commented Jan 24, 2024

Job added to Upwork: https://www.upwork.com/jobs/~0179cecbe3829d643a

@melvin-bot melvin-bot bot changed the title Task - Deleted task gets highlighted and chat turns bold after deletion [$500] Task - Deleted task gets highlighted and chat turns bold after deletion Jan 24, 2024
Copy link

melvin-bot bot commented Jan 24, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 24, 2024
Copy link

melvin-bot bot commented Jan 24, 2024

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

@paultsimura
Copy link
Contributor

Proposal

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

When deleting a task, the parent chat report becomes unread.

What is the root cause of that problem?

When canceling a task, we optimistically update the parent report's lastVisibleActionCreated, which marks the report as unread:

{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${parentReport?.reportID}`,
value: {
lastMessageText: ReportActionsUtils.getLastVisibleMessage(parentReport?.reportID ?? '', optimisticReportActions as OnyxTypes.ReportActions).lastMessageText ?? '',
lastVisibleActionCreated:
ReportActionsUtils.getLastVisibleAction(parentReport?.reportID ?? '', optimisticReportActions as OnyxTypes.ReportActions)?.childLastVisibleActionCreated ?? 'created',
},
},

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

Comparing the optimistic data to the API response (which should be mostly identical), the API response does not update the lastVisibleActionCreated of the parent report.
And logically, this CancelTask operation only modified the parent report action, it does not create a new action in the parent report.
Therefore, we shouldn't update the parentReport.lastVisibleActionCreated optimistically. We only should update the lastMessageText:

        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT}${parentReport?.reportID}`,
            value: {
                lastMessageText: ReportActionsUtils.getLastVisibleMessage(parentReport?.reportID ?? '', optimisticReportActions as OnyxTypes.ReportActions).lastMessageText ?? '',
-                lastVisibleActionCreated:
-                    ReportActionsUtils.getLastVisibleAction(parentReport?.reportID ?? '', optimisticReportActions as OnyxTypes.ReportActions)?.childLastVisibleActionCreated ?? 'created',
            },
        },

Result

Screen.Recording.2024-01-24.at.22.24.50.mov

What alternative solutions did you explore? (Optional)

@allroundexperts
Copy link
Contributor

allroundexperts commented Jan 24, 2024

@paultsimura proposal has the correct RCA and seems to work fine. Let's go with them.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Jan 24, 2024

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

@tienifr
Copy link
Contributor

tienifr commented Jan 25, 2024

Proposal

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

The "Deleted task" message is highlighted and the chat gets bold in LHN

What is the root cause of that problem?

This comes from this change in a TS migration

This is the old code before that:

lastVisibleActionCreated: lodashGet(ReportActionsUtils.getLastVisibleAction(parentReport.reportID, optimisticReportActions), 'created')

This is the new updated code

lastVisibleActionCreated:
                    ReportActionsUtils.getLastVisibleAction(parentReport?.reportID ?? '', optimisticReportActions as OnyxTypes.ReportActions)?.childLastVisibleActionCreated ?? 'created',

So there was a misunderstanding of the 'created' as being the default value, it's actually a field name that's used in lodashGet in the previous code.

This leads to the new code using the childLastVisibleActionCreated which is wrong compared to previous logic. The previous logic is correct (using created) because in this case we need to set the lastVisibleActionCreated back to the created of the last visible report action.

There're 2 cases:

  • If the deleted task doesn't have any child visible action, it will be gone completely once deleted, and the lastVisibleActionCreated will become the created of the last visible action before the deleted task
  • If the deleted task has child visible action, it will become [Deleted task] in the parent report with a thread reply. In this case lastVisibleActionCreated is still the deleted task created, and getLastVisibleAction already accounts for that logic

In both cases above, the previous logic works fine and aligns with the back-end's returned lastVisibleActionCreated when online

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

Revert to using .created like before the TS migration.

lastVisibleActionCreated:
                    ReportActionsUtils.getLastVisibleAction(parentReport?.reportID ?? '', optimisticReportActions as OnyxTypes.ReportActions)?.created

The lastVisibleActionCreated is there for a use case explained above and we can't just remove it. If we remove it, the lastVisibleActionCreated of parent report will be wrong in case of If the deleted task doesn't have any child visible action

What alternative solutions did you explore? (Optional)

NA

@tienifr
Copy link
Contributor

tienifr commented Jan 25, 2024

@allroundexperts I think the RCA and solution accepted seem incorrect, would you mind taking a look at my proposal to see if it makes more sense, thanks!

@allroundexperts
Copy link
Contributor

Hi @tienifr!

Thank you pointing this out. I've reviewed your proposal and I think you're right, we should just revert back to the previous change instead. @marcochavezf Let's go with @tienifr's proposal.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Jan 25, 2024

Current assignee @marcochavezf is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@paultsimura
Copy link
Contributor

Good catch @tienifr💪🏽

@kubabutkiewicz
Copy link
Contributor

Hello guys,
My PR introduced that bug and I checked now that @tienifr solution is resolving only one issue which is chat gets bold in LHN. We also need to remove that line

reportActionID: '',
since its causing this
const isReportActionLinked = props.linkedReportActionID === props.action.reportActionID;
to true and this will cause that Deleted task gets highlighted because of those lines
const highlightedBackgroundColorIfNeeded = useMemo(
() => (isReportActionLinked ? StyleUtils.getBackgroundColorStyle(theme.hoverComponentBG) : {}),
[StyleUtils, isReportActionLinked, theme.hoverComponentBG],
);
. Should I create a PR @allroundexperts since its my PR did this regression?

@allroundexperts
Copy link
Contributor

If its in the regression period, then I think you should create one.

@kubabutkiewicz
Copy link
Contributor

it is , so I am going to created one shortly. Thanks!

@tienifr
Copy link
Contributor

tienifr commented Jan 26, 2024

We also need to remove that line

@kubabutkiewicz I don't think we should remove that line.

We should instead make this condition more robust by checking that props.linkedReportActionID and props.action.reportActionID are not empty before comparing. isReportActionLinked should never be true if those are equal but both empty

@allroundexperts
Copy link
Contributor

Update: Asked @akinwale to review the PR since it was within the regression period and he was the C+.

@dylanexpensify
Copy link
Contributor

TY @allroundexperts! @akinwale can you post an update please? 🙇‍♂️

@akinwale
Copy link
Contributor

TY @allroundexperts! @akinwale can you post an update please? 🙇‍♂️

I'll review today.

@dylanexpensify
Copy link
Contributor

TY! @akinwale update please?

@akinwale
Copy link
Contributor

akinwale commented Feb 7, 2024

@dylanexpensify Review completed and the PR was merged. #35252 (comment)

@dylanexpensify
Copy link
Contributor

Woooot!

@tienifr
Copy link
Contributor

tienifr commented Feb 15, 2024

@dylanexpensify Since the PR uses RCA and solution from my proposal here and here, could you assign me to this GH for compensation (same as this case), thanks!

@dylanexpensify
Copy link
Contributor

sure can!

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 21, 2024
Copy link

melvin-bot bot commented Feb 21, 2024

📣 @tienifr 🎉 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 📖

@tienifr
Copy link
Contributor

tienifr commented Feb 21, 2024

@dylanexpensify Thanks! I've accepted the offer. Since the PR was deployed to production 2 weeks ago without regressions, I think we can move forward with payments.

@dylanexpensify
Copy link
Contributor

Agree, paying today!

@dylanexpensify
Copy link
Contributor

@tienifr paid out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
None yet
Development

No branches or pull requests

8 participants