Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.58k stars 2.92k forks source link

Chat - Newline marker is shown on system message when returning back to the expense thread #53000

Open lanitochka17 opened 1 week ago

lanitochka17 commented 1 week ago

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: 9.0.66-0 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Email or phone of affected tester (no customers): applausetester+bg@applause.expensifail.com Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/
  2. Create an expense in workspace chat
  3. Go to report and add a category.
  4. Notice system message is create but no newline shown.
  5. Go back to the main chat and return to the report

Expected Result:

Newline marker is not shown

Actual Result:

Newline marker is shown

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/user-attachments/assets/9bfee331-3303-4eae-8a95-41a29240823c

View all open jobs on GitHub

melvin-bot[bot] commented 1 week ago

Triggered auto assignment to @strepanier03 (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.

bernhardoj commented 1 week ago

Proposal

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

New message marker shows for update category system message.

What is the root cause of that problem?

This only happens in a one expense report. In a one expense report, when we edit the money request, the edit system message is added to the transaction thread. The one expense report shows a combined report actions between the expense report itself and the transaction thread. For showing the new message marker, we compare the unreadMarkerTime (report last read time) with the action created value. https://github.com/Expensify/App/blob/3ebe8520d74c57a2fe9548b7d4307206e2b7c673/src/pages/home/report/ReportActionsList.tsx#L278

Since editing the money request adds the action to the transaction thread, the expense report lastReadTime is unchanged and the edit system message created is bigger than the expense report lastReadTime, thus the new message line is shown.

Why this only happen after reopening the report? It's because we set the unread marker to the report lastReadTime once and then it gets updated when there is a new message, which is the edit system message in this case. https://github.com/Expensify/App/blob/3ebe8520d74c57a2fe9548b7d4307206e2b7c673/src/pages/home/report/ReportActionsList.tsx#L346-L351

But when we reopen the report, the unreadMarkerTime is set with the expense report lastReadTime.

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

We should use the transaction thread report lastReadTime if it's bigger than the expense report lastReadTime, similar to what we did to lastVisibleActionCreated. https://github.com/Expensify/App/blob/3ebe8520d74c57a2fe9548b7d4307206e2b7c673/src/pages/home/report/ReportActionsList.tsx#L358-L361

const lastReadTime =
    (transactionThreadReport?.lastReadTime ?? '') > reportLastReadTime
        ? transactionThreadReport?.lastReadTime
        : reportLastReadTime;

const [unreadMarkerTime, setUnreadMarkerTime] = useState(lastReadTime);
useEffect(() => {
    setUnreadMarkerTime(lastReadTime);

    // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [report.reportID]);
melvin-bot[bot] commented 4 days ago

@strepanier03 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

melvin-bot[bot] commented 2 days ago

@strepanier03 Huh... This is 4 days overdue. Who can take care of this?