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 details are not immediately removed after navigating back to a task using the back button browser #27728

Closed
thienlnam opened this issue Sep 19, 2023 · 28 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@thienlnam
Copy link
Contributor

thienlnam commented Sep 19, 2023

Found as part of #24137

  1. Go offline
  2. Create a task and open the task detail
  3. Send a message
  4. Right-click on the message and select reply in a thread
  5. Press the browser back button
  6. Cancel the task

Expected:
The task details show show [Canceled Task] without having to refresh the page

Actual:
The task details are shown, and require a refresh before [Cancel Task] is shown

Platform:
Web

OFFLINE
Untitled.mov
ONLINE
Screen.Recording.2023-09-12.at.21.15.30.mov
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01815b4d02dffa34d6
  • Upwork Job ID: 1703948271970603008
  • Last Price Increase: 2023-09-26
@thienlnam thienlnam added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 19, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 19, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 19, 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

@thienlnam thienlnam added the External Added to denote the issue can be worked on by a contributor label Sep 19, 2023
@melvin-bot melvin-bot bot changed the title Task details are not immediately removed after navigating back to a task using the back button browser [$500] Task details are not immediately removed after navigating back to a task using the back button browser Sep 19, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 19, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01815b4d02dffa34d6

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

melvin-bot bot commented Sep 19, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 19, 2023

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

@imranaalam
Copy link

@thienlnam
what to expect?
what happened?

@imranaalam
Copy link

@thienlnam
which platform?

@thienlnam
Copy link
Contributor Author

Added some more details

@dukenv0307
Copy link
Contributor

dukenv0307 commented Sep 19, 2023

@thienlnam
I cannot reproduce it in the latest main.

Screencast.from.19-09-2023.09.38.54.webm

@dukenv0307
Copy link
Contributor

@thienlnam

But I saw we have another bug: the last message in LHN of cancelled task report is different when offline and online. Do you think we should fix it here or it is in progress?

@thienlnam
Copy link
Contributor Author

But I saw we have another bug: the last message in LHN of cancelled task report is different when offline and online. Do you think we should fix it here or it is in progress?

Is it that one shows cancelled and the other shows deleted? We're aligning task system messages in a different issue

@dukenv0307
Copy link
Contributor

Is it that one shows cancelled and the other shows deleted.

Yes.

@Nodebrute
Copy link
Contributor

Nodebrute commented Sep 19, 2023

Proposal

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

When we navigate using the browser back button task details are not removed.

What is the root cause of that problem?

In the memo function, we do not trigger a re-render when we cancel a task report. As a result, when we navigate using the browser's back button, the component does not re-render, and we continue to see the old data.

An additional approach to verify whether the issue is associated with the memoization HOC is to temporarily remove the memoization HOC and check if the problem persists which, in this case, does not persist.

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

We can add another condition in the Memo function to check if the task report is canceled.

const parentReportActionPrev = ReportActionsUtils.getParentReportAction(prevProps.report);
const parentReportActionNext = ReportActionsUtils.getParentReportAction(nextProps.report);
  ReportUtils.isCanceledTaskReport(prevProps.report, parentReportActionPrev) ===
  ReportUtils.isCanceledTaskReport(nextProps.report, parentReportActionNext)

Sample code to test

 memo(
        ReportActionItem,
        (prevProps, nextProps) =>{
            const parentReportActionPrev = ReportActionsUtils.getParentReportAction(prevProps.report);
            const parentReportActionNext = ReportActionsUtils.getParentReportAction(nextProps.report);
            console.log(parentReportActionNext === parentReportActionPrev)
            return(
                prevProps.displayAsGroup === nextProps.displayAsGroup &&
         ........Omitted code for readability
           ReportUtils.isCanceledTaskReport(prevProps.report, parentReportActionPrev) ===
            ReportUtils.isCanceledTaskReport(nextProps.report, parentReportActionNext)
            )
        }
            
    ),

Works as expected

Screen.Recording.2023-09-19.at.8.43.08.AM.mov

What alternative solutions did you explore? (Optional)

As getParentReportAction is being deprecated. Therefore, we can replace it with withOnyx() to obtain the latest value.

@mollfpr
Copy link
Contributor

mollfpr commented Sep 19, 2023

I am still able to reproduce the issue in the latest main.

Screen.Recording.2023-09-19.at.21.39.22.mov

@dylanexpensify
Copy link
Contributor

@mollfpr mind giving a review on above proposal?

@mollfpr
Copy link
Contributor

mollfpr commented Sep 19, 2023

ReportUtils.isCanceledTaskReport(prevProps.report, prevProps.parentReportAction) ===
ReportUtils.isCanceledTaskReport(nextProps.report, nextProps.parentReportAction)

@Nodebrute Why parentReportAction become a prop? Why the issue is reproduced with the browser back button?

@Nodebrute
Copy link
Contributor

Hey, yeah, @mollfpr , you are right. It was a mistake. We can do it like this

     const parentReportActionPrev = ReportActionsUtils.getParentReportAction(prevProps.report);
     const parentReportActionNext = ReportActionsUtils.getParentReportAction(nextProps.report);

And then we can use this to trigger re-render.

@Nodebrute
Copy link
Contributor

@mollfpr It has also come to my attention that getParentReportAction is being deprecated. Therefore, we can replace it with withOnyx() to obtain the latest value.

* Returns the parentReportAction if the given report is a thread/task.
*
* @param {Object} report
* @param {Object} [allReportActionsParam]
* @returns {Object}
* @deprecated Use Onyx.connect() or withOnyx() instead
*/
function getParentReportAction(report, allReportActionsParam = undefined) {

@mollfpr
Copy link
Contributor

mollfpr commented Sep 19, 2023

@Nodebrute I think it might work. Please update your proposal when you are ready.

@Nodebrute
Copy link
Contributor

@mollfpr Updated. Please consider reviewing.

@mollfpr
Copy link
Contributor

mollfpr commented Sep 21, 2023

The issue is not reproduced on staging and DEV.

@paultsimura
Copy link
Contributor

@DylanDylann
Copy link
Contributor

Proposal

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

Task details are not immediately removed after navigating back to a task using the back button browser

What is the root cause of that problem?

When deleting task, isDeletedParentAction of task report will be true. But when isDeletedParentAction changed we don't re-render ReportActionItem

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

memo(
ReportActionItem,
(prevProps, nextProps) =>

In here we should add

lodashGet(prevProps.report, 'isDeletedParentAction') === lodashGet(nextProps.report, 'isDeletedParentAction') &&

What alternative solutions did you explore? (Optional)

@dylanexpensify
Copy link
Contributor

@mollfpr let's confirm reproducibility comment here, and if valid review @DylanDylann's proposal!

@melvin-bot melvin-bot bot removed the Overdue label Sep 25, 2023
@mollfpr
Copy link
Contributor

mollfpr commented Sep 25, 2023

I still couldn't reproduce it on v1.3.74-1 latest main. @DylanDylann Could you confirm if this issue is still reproducible?

@DylanDylann
Copy link
Contributor

Couldn't reproduce

@melvin-bot
Copy link

melvin-bot bot commented Sep 26, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@thienlnam
Copy link
Contributor Author

Thank you all - I'll go ahead and close since we can't seem to reproduce anymore

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. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

8 participants