You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$500] LHN - Selecting Mark as unread not displaying chat in bold #33881
Version Number: 1.4.21 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 Expensify/Expensify Issue URL: Issue reported by: Applause - Internal Team Slack conversation:
changed the title [-]LHN - Selecting Mark as unread not displaying chat in bold[/-][+][$500] LHN - Selecting Mark as unread not displaying chat in bold[/+]on Jan 3, 2024
Please re-state the problem that we are trying to solve in this issue.
Mark as unred is not marking the report as unread (no bold effect)
What is the root cause of that problem?
the function markCommentAsUnread from report.ts needs data from Onyx.
The moments we try to mark the report as unred, the data of this report, is not available on Onyx
If we check from dev tool, application, Onyx database, we will not find the "report_Actions_xxxxxxxxx" of the report.
If we open the report, then mark it unred, it works, because the Onyx data is updated.
The function markCommentAsUnread subtract 1 millisecond from actionCreationTime to update lastReadTime with the new value. if no OnyxData and reportActions is undefined, then lastReadTime will be minus 1 millisecond from DateUtils.getDBTime(0)
// We subtract 1 millisecond so that the lastReadTime is updated to just before a given reportAction's created date
// For example, if we want to mark a report action with ID 100 and created date '2014-04-01 16:07:02.999' unread, we set the lastReadTime to '2014-04-01 16:07:02.998'
// Since the report action with ID 100 will be the first with a timestamp above '2014-04-01 16:07:02.998', it's the first one that will be shown as unread
With the new lastReadTime time (wrong one), The function isUnread will compare lastReadTime < lastVisibleActionCreated where the new lastReadTime is wrong (minus 1 ms from DateUtils.getDBTime(0) and not lastVisibleActionCreated)
We can use openReport(reportID); from the same file to update the OnyxData, then reportActions will not turn undefined.
What alternative solutions did you explore? (Optional)
We can update the Onyx data when the user press on item from LHNOptionsList. The onPress will use a function like fetchReportIfNeeded, then do the markCommentAsUnread
@dragnoir Your solution works partially. Adding openReport call inside the markAsUnread function doesn't make it bold on the first time. You have to mark it as unread, wait for a few seconds and then mark is as unread again in order to make the bolding work.
// We subtract 1 millisecond so that the lastReadTime is updated to just before a given reportAction's created date
// For example, if we want to mark a report action with ID 100 and created date '2014-04-01 16:07:02.999' unread, we set the lastReadTime to '2014-04-01 16:07:02.998'
// Since the report action with ID 100 will be the first with a timestamp above '2014-04-01 16:07:02.998', it's the first one that will be shown as unread
The report action that we mark as unread, but this is not the case for us because we mark it from LHN, so it's undefined
The last report action of other users from the report actions onyx
Fallback to current time
But in our case, the report's report actions Onyx is not available yet, so the 2nd case fails too and falls back to the current time, so lastReadTime is always > lastVisibleActionCreated.
This is the regression from #32958 where we remove the fallback of the current report's lastVisibleActionCreated.
What changes do you think we should make in order to solve the problem?
Add back the fallback of the report's lastVisibleActionCreated
You need to logout and then login. Without opening the report, try marking it as unread.
I personally don't see a real world scenario for this. We typically mark messages as unread to get back to them later, after reading them, which means the report actions will be loaded. We also use infinite sessions so our typical users will only need to log in once.
@youssef-lr I agree that it would be rare for any real user to encounter this case, but this works fine before #32958, so I think it makes sense if we fix it here.
Activity
[-]LHN - Selecting Mark as unread not displaying chat in bold[/-][+][$500] LHN - Selecting Mark as unread not displaying chat in bold[/+]melvin-bot commentedon Jan 3, 2024
Job added to Upwork: https://www.upwork.com/jobs/~010c13f72ee15736be
melvin-bot commentedon Jan 3, 2024
Triggered auto assignment to @slafortune (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Jan 3, 2024
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Jan 3, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @allroundexperts (
External)namhihi237 commentedon Jan 3, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Selecting "Mark as unread" must display chat in bold in LHN.
What is the root cause of that problem?
Currently in the
OptionRowLHNmenu context here, we pass '0' as the reportActionIDApp/src/components/LHNOptionsList/OptionRowLHN.js
Lines 130 to 136 in 3826e5d
So that here it will take current time.
App/src/libs/actions/Report.ts
Lines 954 to 955 in 2fe1174
What changes do you think we should make in order to solve the problem?
We should get the last report action if we do not pass the reportAction
Result:
Screen.Recording.2024-01-04.at.00.38.35.mov
What alternative solutions did you explore? (Optional)
We should pass the last report action ID here.
Get reportActions from
OptionRowLHNData.dragnoir commentedon Jan 3, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Mark as unred is not marking the report as unread (no bold effect)
What is the root cause of that problem?
the function
markCommentAsUnreadfrom report.ts needs data from Onyx.The moments we try to mark the report as unred, the data of this report, is not available on Onyx
If we check from dev tool, application, Onyx database, we will not find the "report_Actions_xxxxxxxxx" of the report.
If we open the report, then mark it unred, it works, because the Onyx data is updated.
The function
markCommentAsUnreadsubtract 1 millisecond fromactionCreationTimeto updatelastReadTimewith the new value. if no OnyxData andreportActionsis undefined, then lastReadTime will be minus 1 millisecond fromDateUtils.getDBTime(0)App/src/libs/actions/Report.ts
Lines 955 to 960 in 3b385ef
With the new lastReadTime time (wrong one), The function isUnread will compare
lastReadTime < lastVisibleActionCreatedwhere the new lastReadTime is wrong (minus 1 ms from DateUtils.getDBTime(0) and not lastVisibleActionCreated)App/src/libs/ReportUtils.ts
Lines 3293 to 3302 in 3b385ef
What changes do you think we should make in order to solve the problem?
We need to update Onyx data on
markCommentAsUnreadbefore calling the data from the local storage.App/src/libs/actions/Report.ts
Line 943 in 3b385ef
We can use
openReport(reportID);from the same file to update the OnyxData, thenreportActionswill not turnundefined.What alternative solutions did you explore? (Optional)
We can update the Onyx data when the user press on item from LHNOptionsList. The onPress will use a function like
fetchReportIfNeeded, then do themarkCommentAsUnreadbernhardoj commentedon Jan 4, 2024
Looks like a regression from #32958.
situchan commentedon Jan 4, 2024
I am not able to reproduce on latest main
8 remaining items
allroundexperts commentedon Jan 14, 2024
@dragnoir Your solution works partially. Adding
openReportcall inside themarkAsUnreadfunction doesn't make it bold on the first time. You have to mark it as unread, wait for a few seconds and then mark is as unread again in order to make the bolding work.allroundexperts commentedon Jan 14, 2024
Still looking for better proposals.
bernhardoj commentedon Jan 14, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Mark as unread on some chat doesn't turn the title to bold/
What is the root cause of that problem?
The title will turn to bold if
ReportUtils.isUnreadreturns true. It compares iflastReadTime < lastVisibleActionCreatedApp/src/libs/ReportUtils.ts
Line 3350 in fd45dea
When pressing the mark as unread, it will take the report action created time subtracted by 1.
App/src/libs/actions/Report.ts
Lines 955 to 968 in fd45dea
The report action created time that we take is:
But in our case, the report's report actions Onyx is not available yet, so the 2nd case fails too and falls back to the current time, so
lastReadTimeis always >lastVisibleActionCreated.This is the regression from #32958 where we remove the fallback of the current report's
lastVisibleActionCreated.What changes do you think we should make in order to solve the problem?
Add back the fallback of the report's
lastVisibleActionCreatedallroundexperts commentedon Jan 14, 2024
If we decide to fix this here, then @bernhardoj's proposal looks good to me!
🎀 👀 🎀 C+ reviewed
melvin-bot commentedon Jan 14, 2024
Triggered auto assignment to @youssef-lr, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
youssef-lr commentedon Jan 14, 2024
This is no longer reproducible.
allroundexperts commentedon Jan 14, 2024
@youssef-lr This is easily reproducible. You need to logout and then login. Without opening the report, try marking it as unread.
youssef-lr commentedon Jan 14, 2024
I personally don't see a real world scenario for this. We typically mark messages as unread to get back to them later, after reading them, which means the report actions will be loaded. We also use infinite sessions so our typical users will only need to log in once.
bernhardoj commentedon Jan 15, 2024
@youssef-lr I agree that it would be rare for any real user to encounter this case, but this works fine before #32958, so I think it makes sense if we fix it here.
situchan commentedon Jan 15, 2024
If this should be fixed, should be treated as regression from #32958.
cc: @MonilBhavsar
youssef-lr commentedon Jan 15, 2024
Thanks @situchan, I reopened #31748.