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 2024-05-08] [$250] Task – When task name is changed offline, the task's chat report in the LHN doesn't update after going back online #40121

Closed
1 of 6 tasks
m-natarajan opened this issue Apr 11, 2024 · 22 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

@m-natarajan
Copy link

m-natarajan commented Apr 11, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v1.4.62-0

Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4486193
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. Go to https://staging.new.expensify.com/
  2. Log in.
  3. Go to any chat
  4. Create a task with assignee
  5. Go Offline and edit task name
  6. Go back Online and observe task name in a DM chat in LHN (not task details)

Expected Result:

Offline edited task name changed without delay in DM chat LHN

Actual Result:

Offline edited task name changed with delay in DM chat LHN when go Online. Task name in LHN must be changed when Offline

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

Bug6445047_1712779489342.Task_name.mp4

Bug6445047_1712787643540!Log.txt.txt

Add any screenshot/video evidence

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~018db3c535ab60f25e
  • Upwork Job ID: 1779911172994191360
  • Last Price Increase: 2024-04-15
  • Automatic offers:
    • getusha | Reviewer | 0
    • bernhardoj | Contributor | 0
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Apr 11, 2024
Copy link

melvin-bot bot commented Apr 11, 2024

Triggered auto assignment to @sakluger (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@m-natarajan
Copy link
Author

@sakluger FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors.

@m-natarajan
Copy link
Author

We think this bug might be related to #vip-vsb

@nkdengineer
Copy link
Contributor

nkdengineer commented Apr 11, 2024

Proposal

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

Offline edited task name changed with delay in DM chat LHN when go Online. Task name in LHN must be changed when Offline

What is the root cause of that problem?

When we edit the task title, editTask function is called and in optimistic data we don't update anything for parentReportAction so the OptionRowLHN of parent report isn't re-rendered. After EditTask API is complete, back-end returns the update data for parentReportAction like this, the filed change is childReportName leading the LHN row of parent report is rendered and then last message text is updated.

Screenshot 2024-04-11 at 22 58 02

function editTask(report: OnyxTypes.Report, {title, description}: OnyxTypes.Task) {

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

When we edit the title of the task we should update childReportName of parentReportAction in optimisticData and reset it in failureData so the last message text of parent report can be updated in LHN.

if (reportName !== report.reportName) {
    optimisticData.push({
        onyxMethod: Onyx.METHOD.MERGE,
        key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`,
        value: {
            [report.parentReportActionID ?? '0']: {
                childReportName: title
            }
        }
    })

    failureData.push({
        onyxMethod: Onyx.METHOD.MERGE,
        key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`,
        value: {
            [report.parentReportActionID ?? '0']: {
                childReportName: report.reportName
            }
        }
    })
}

function editTask(report: OnyxTypes.Report, {title, description}: OnyxTypes.Task) {

What alternative solutions did you explore? (Optional)

NA

@bernhardoj
Copy link
Contributor

Proposal

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

When we update the task title, the LHN of the chat report doesn't update with the new title.

What is the root cause of that problem?

The task title in the LHN last message takes the title from getTaskTitle.

function getTaskTitle(taskReportID: string, fallbackTitle = ''): string {
const taskReport = allReports?.[taskReportID] ?? {};
// We need to check for reportID, not just reportName, because when a receiver opens the task for the first time,
// an optimistic report is created with the only property – reportName: 'Chat report',
// and it will be displayed as the task title without checking for reportID to be present.
return Object.hasOwn(taskReport, 'reportID') && 'reportName' in taskReport && typeof taskReport.reportName === 'string' ? taskReport.reportName : fallbackTitle;
}
function getTaskCreatedMessage(reportAction: OnyxEntry<ReportAction>) {
const taskReportID = reportAction?.childReportID ?? '';
const taskTitle = getTaskTitle(taskReportID, reportAction?.childReportName);
return taskTitle ? Localize.translateLocal('task.messages.created', {title: taskTitle}) : '';
}

getTaskTitle will first get the title from the task report reportName and fallback to the task action childReportName. When we edit the task, we already optimistically update the task report reportName.

onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`,
value: {
reportName,

However, getTaskTitle never use reportName. That is because the task report here is always an empty object because we access it incorrectly

function getTaskTitle(taskReportID: string, fallbackTitle = ''): string {
const taskReport = allReports?.[taskReportID] ?? {};

allReports contains the collection of the report which is keyed by report_{id} but we try to access it with {id}. This started to happen after #38464. Previously, allReports is keyed by {id}.
image

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

Access the task report by report_{id}.

const taskReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`] ?? {};

What alternative solutions did you explore? (Optional)

Use the old approach by keyed it with {id} and remove waitForCollectionCallback.

let allReports: OnyxCollection<Report> = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (reports) => {
allReports = reports;
},
});

@melvin-bot melvin-bot bot added the Overdue label Apr 15, 2024
@sakluger sakluger added the External Added to denote the issue can be worked on by a contributor label Apr 15, 2024
@melvin-bot melvin-bot bot changed the title Task – Offline edited task name changed with delay in DM chat LHN [$250] Task – Offline edited task name changed with delay in DM chat LHN Apr 15, 2024
Copy link

melvin-bot bot commented Apr 15, 2024

Job added to Upwork: https://www.upwork.com/jobs/~018db3c535ab60f25e

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

melvin-bot bot commented Apr 15, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Apr 15, 2024
@sakluger sakluger changed the title [$250] Task – Offline edited task name changed with delay in DM chat LHN [$250] Task – When task name is changed offline, the task's chat report in the LHN doesn't update after going back online Apr 15, 2024
@getusha
Copy link
Contributor

getusha commented Apr 16, 2024

@bernhardoj's proposal looks good to me.
🎀 👀 🎀 C+ Reviewed.

Copy link

melvin-bot bot commented Apr 16, 2024

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

@lakchote
Copy link
Contributor

@bernhardoj's proposal LGTM.

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

melvin-bot bot commented Apr 17, 2024

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

Offer link
Upwork job

Copy link

melvin-bot bot commented Apr 17, 2024

📣 @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: @getusha

@melvin-bot melvin-bot bot added Reviewing Has a PR in review and removed Daily KSv2 labels Apr 17, 2024
@melvin-bot melvin-bot bot added the Weekly KSv2 label Apr 17, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels May 1, 2024
@melvin-bot melvin-bot bot changed the title [$250] Task – When task name is changed offline, the task's chat report in the LHN doesn't update after going back online [HOLD for payment 2024-05-08] [$250] Task – When task name is changed offline, the task's chat report in the LHN doesn't update after going back online May 1, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 1, 2024
Copy link

melvin-bot bot commented May 1, 2024

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

Copy link

melvin-bot bot commented May 1, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.68-3 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 2024-05-08. 🎊

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

Copy link

melvin-bot bot commented May 1, 2024

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:

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels May 7, 2024
@sakluger
Copy link
Contributor

sakluger commented May 8, 2024

Hey @getusha could you please accept the Upwork offer? https://www.upwork.com/nx/wm/offer/101905561

@sakluger
Copy link
Contributor

sakluger commented May 8, 2024

I paid @bernhardoj's contract. @bernhardoj could you please complete the BZ checklist?

@bernhardoj
Copy link
Contributor

@sakluger I think @getusha should be the one that complete the checklist

@sakluger
Copy link
Contributor

@bernhardoj you're right, my bad! @getusha please complete the checklist when you have a moment.

@getusha
Copy link
Contributor

getusha commented May 10, 2024

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:

@sakluger
Copy link
Contributor

Thanks! All paid out.

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
No open projects
Archived in project
Development

No branches or pull requests

6 participants