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

Edited thread message does not update in LHN. #23897

Closed
1 of 6 tasks
kavimuru opened this issue Jul 30, 2023 · 9 comments
Closed
1 of 6 tasks

Edited thread message does not update in LHN. #23897

kavimuru opened this issue Jul 30, 2023 · 9 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2

Comments

@kavimuru
Copy link

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


Action Performed:

  1. Open App and Go to any chat
  2. Send a message in the Chat
  3. Press Reply in the thread option on the sent message; it will navigate to the thread page
  4. Edit the thread main message and observe the LHN title of the active thread

Expected Result:

LHN thread title should show the edited message.

Actual Result:

LHN shows the old message.

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.47-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:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

thread-hedaer-message.mov
Recording.1406.mp4

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

View all open jobs on GitHub

@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 30, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 30, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 30, 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

@s-alves10
Copy link
Contributor

s-alves10 commented Jul 30, 2023

Proposal

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

Editing the first message of a thread doesn't change the title in LHN

What is the root cause of that problem?

The LHN contents is updated when the report is updated as you can see here

const optionItem = useMemo(() => {
// Note: ideally we'd have this as a dependent selector in onyx!
const item = SidebarUtils.getOptionData(fullReport, personalDetails, preferredLocale, policy);
if (deepEqual(item, optionItemRef.current)) {
return optionItemRef.current;
}
optionItemRef.current = item;
return item;
}, [fullReport, personalDetails, preferredLocale, policy]);

But when edit the first thread message, only the parent report is changed and the thread report is not changed. Please refer

App/src/libs/actions/Report.js

Lines 1095 to 1099 in eb02006

optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${originalReportID}`,
value: optimisticReport,
});

In the above code, the originalReportID is parent report ID for the first thread message. As you can see, the thread report isn't being updated.

This is the root cause.

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

We need to change the thread report when the first thread message is updated

    if (originalReportID.toString() !== reportID.toString()) {
        // For the first thread message, we need to update the thread report as well
        optimisticData.push({
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
            value: {
                lastReadTime: DateUtils.getDBTime()
            }
        });     
    }

This works great

Result
23897.mp4

What alternative solutions did you explore? (Optional)

@pravinkumar57
Copy link

Proposal

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

Editing the first message of a thread doesn't change the title in LHN

What is the root cause of that problem?

That issue is not present in the latest code of the project (I have checked from the MAIN branch), The last message edit is being reflected in the side bar section.

There is another issue similar to this, If you try to edit any other message not the last message, Changes does not reflected to the sidebar section.

Here is the attached video, Where last message edit is working fine but any other message edit is not being updated in the side section.

LastMessageHasEffect1.mov

The Root cause of this issue is

App/src/libs/actions/Report.js

Lines 1089 to 1100 in 62622e9

if (reportActionID === lastVisibleAction.reportActionID) {
const lastMessageText = ReportUtils.formatReportLastMessageText(reportComment);
const optimisticReport = {
lastMessageTranslationKey: '',
lastMessageText,
};
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${originalReportID}`,
value: optimisticReport,
});
}

Here, If the reportActionID matches the lastVisibleAction.reportID, then it show the effect. and for a report the lastvisibleAction is adding a comment, which will be the last comment added.

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

The solution to this problem is to update the message itself which is being edited when it's not the last message of any report.

We will replace the above if section with the following code.

if (reportActionID === lastVisibleAction.reportActionID) {
    const lastMessageText = ReportUtils.formatReportLastMessageText(reportComment);
    const optimisticReport = {
        lastMessageTranslationKey: '',
        lastMessageText,
    };
    optimisticData.push({
        onyxMethod: Onyx.METHOD.MERGE,
        key: `${ONYXKEYS.COLLECTION.REPORT}${originalReportID}`,
        value: optimisticReport,
    });
} {
    optimisticData.push({
        onyxMethod: Onyx.METHOD.MERGE,
        key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
        value: {
            lastReadTime: DateUtils.getDBTime(),
        },
    });
}

After the above solution, every message editing will have the effect in the side bar as shown in the video.

EveryMessageEffect.mov

What alternative solutions did you explore? (Optional)

N/A

@melvin-bot
Copy link

melvin-bot bot commented Jul 31, 2023

📣 @pravinkumar57! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  2. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  3. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@pravinkumar57
Copy link

Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/pravinetom

@melvin-bot
Copy link

melvin-bot bot commented Jul 31, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@dukenv0307
Copy link
Contributor

Dupe here: #23424

@johncschuster
Copy link
Contributor

Thanks for flagging that, @dukenv0307! Let's close this issue in favor of #23424

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
Projects
None yet
Development

No branches or pull requests

5 participants