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
[Due for payment 2025-05-27] [$250] Chat - Unread marker displayed constantly on chat after keeping one duplicate expense. #58673
Version Number: 9.1.15-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes, reproducible on both If this was caught during regression testing, add the test name, ID and link from TestRail:#58382 Email or phone of affected tester (no customers):ibellicotest+416@gmail.com Issue reported by: Applause Internal Team Device used: Motorola MotoG60 - Android 12 - Chrome / Windows 10 - Chrome App Component: Chat Report View
Action Performed:
Open the staging.new.expensify.com website.
Open any workspace chat.
Create two identical expenses.
Open the expenses report.
Tap on any of the two expenses.
Dismiss the "Hold" modal.
Tap on "Review duplicates" and "Keep this one" on any of the two expenses.
Tap on "Confirm"
Return to conversation.
Note that now, an unread marker is displayed above expense report.
Return to LHN and open chat again.
Check if unread marker is still displayed.
Expected Result:
Unread marker shouldn´t appear on chat after keeping one of the duplicates expenses.
Actual Result:
Unread marker appears above expense report, after finishing the review duplicates process and keeping only one. Also, unread marker doesn´t disappear after closing and reopening chat. It remains constantly displayed.
changed the title [-]Chat - Unread marker displayed constantly on chat after keeping one duplicate expense.[/-][+][$250] Chat - Unread marker displayed constantly on chat after keeping one duplicate expense.[/+]on Mar 25, 2025
🚨 Edited by proposal-police: This proposal was edited at 2025-03-26 07:15:03 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Chat - Unread marker displayed constantly on chat after keeping one duplicate expense. The unread marker also displayed constantly when we created an expense, switched to another report chats, and again opened the recently created expense report chats.
What is the root cause of that problem?
When we create an expense, we update the unreadMarkerTime at the below line when lastAction.created changes.
But we don't update the report.lastReadTime when any report action is created. That's why unreadMarker doesn't show up when we create an expense, but if we navigate to some other screen and again open the chat where we created Expense recently, then we can see the unreadMarker constantly. When keeping a duplicate expense, we eventually navigated to another screen.
Before_Fix.mp4
And when we returned to our current chat, the unreadMarkerTime was initialized with report.lastReadTime that wasn't updated previously.
Hence, resulting in isReportActionUnread() function returns true because the message.created time is recent but the unreadMarkerTime was initialized with the old report.lastReadTime:
/** * Note: Prefer `ReportActionsUtils.isCurrentActionUnread` over this method, if applicable. * Check whether a specific report action is unread. */functionisReportActionUnread(reportAction: OnyxEntry<ReportAction>,lastReadTime?: string){if(!lastReadTime){return!isCreatedAction(reportAction);}return!!(reportAction&&lastReadTime&&reportAction.created&&lastReadTime<reportAction.created);}
What changes do you think we should make in order to solve the problem?
We can update the report.lastReadTime by calling the readNewestAction function whenever the lastAction.created changes, i.e., a report action is created. However, we're already calling this function inside two effects as shown here:
But, the isUnread function returns false when we create a report action because it compares lastReadTime < lastVisibleActionCreated and both are equal when we create an Expense Report. Hence, the readNewestAction function doesn't get called.
We can refactor the if condition like this:
// If the last action's created time < report's last read time, i.e., the last action created is unread then the condition will be trueif(isUnread(report,transactionThreadReport)||isReportActionUnread(lastAction,report.lastReadTime))
Results
After_Fix.mp4
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
We should write a test in the UnreadIndicatorsTest.tsx file to test behavior when creating an expense.
What alternative solutions did you explore? (Optional)
We can also update the report.lastReadTime by:
Replace setUnreadMarkerTime with readNewestAction because the readNewestAction() function also updates unreadMarkerTime:
/*This useEffect reads the newest action and update report.lastReadTime when: * 1. When the report is opened * 2. When a new action is created */useEffect(()=>{if((isVisible||isFocused)&&scrollingVerticalOffset.current<CONST.REPORT.ACTIONS.ACTION_VISIBLE_THRESHOLD){readNewestAction(report.reportID);}else{readActionSkipped.current=true;}readNewestAction(report.reportID)},[lastAction?.created,report.reportID,isVisible,isFocused])
I would prefer refactoring the whole logic to show the unread marker because I think the code execution is pretty unpredictable right now. Refactoring it would ensure clean code and the desired behavior.
changed the title [-][$250] Chat - Unread marker displayed constantly on chat after keeping one duplicate expense.[/-][+][Due for payment 2025-05-27] [$250] Chat - Unread marker displayed constantly on chat after keeping one duplicate expense.[/+]on May 20, 2025
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.46-12 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@Ollyws@adelekennedy@Ollyws The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
Activity
melvin-bot commentedon Mar 19, 2025
Triggered auto assignment to @adelekennedy (
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.rohit9625 commentedon Mar 21, 2025
I can see the
unread markerjust after creating two same expenses. Don't need to keep an expense.melvin-bot commentedon Mar 24, 2025
@adelekennedy Eep! 4 days overdue now. Issues have feelings too...
[-]Chat - Unread marker displayed constantly on chat after keeping one duplicate expense.[/-][+][$250] Chat - Unread marker displayed constantly on chat after keeping one duplicate expense.[/+]melvin-bot commentedon Mar 25, 2025
Job added to Upwork: https://www.upwork.com/jobs/~021904348606828653423
melvin-bot commentedon Mar 25, 2025
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Ollyws (
External)rohit9625 commentedon Mar 26, 2025
🚨 Edited by proposal-police: This proposal was edited at 2025-03-26 07:15:03 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Chat - Unread marker displayed constantly on chat after keeping one duplicate expense. The unread marker also displayed constantly when we created an expense, switched to another report chats, and again opened the recently created expense report chats.
What is the root cause of that problem?
When we create an expense, we update the
unreadMarkerTimeat the below line whenlastAction.createdchanges.App/src/pages/home/report/ReportActionsList.tsx
Line 351 in ca1f4ff
But we don't update the
report.lastReadTimewhen any report action is created. That's whyunreadMarkerdoesn't show up when we create an expense, but if we navigate to some other screen and again open the chat where we createdExpenserecently, then we can see theunreadMarkerconstantly. When keeping a duplicate expense, we eventually navigated to another screen.Before_Fix.mp4
And when we returned to our current chat, the unreadMarkerTime was initialized with
report.lastReadTimethat wasn't updated previously.App/src/pages/home/report/ReportActionsList.tsx
Lines 203 to 218 in ca1f4ff
Hence, resulting in
isReportActionUnread()function returns true because themessage.createdtime is recent but theunreadMarkerTimewas initialized with the oldreport.lastReadTime:App/src/pages/home/report/ReportActionsList.tsx
Line 268 in ca1f4ff
Above function implementation:
What changes do you think we should make in order to solve the problem?
We can update the
report.lastReadTimeby calling thereadNewestActionfunction whenever thelastAction.createdchanges, i.e., a report action is created. However, we're already calling this function inside two effects as shown here:App/src/pages/home/report/ReportActionsList.tsx
Lines 352 to 365 in 12bb191
But, the
isUnreadfunction returns false when we create a report action because it compareslastReadTime < lastVisibleActionCreatedand both are equal when we create an Expense Report. Hence, thereadNewestActionfunction doesn't get called.We can refactor the if condition like this:
Results
After_Fix.mp4
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
We should write a test in the
UnreadIndicatorsTest.tsxfile to test behavior when creating an expense.What alternative solutions did you explore? (Optional)
We can also update the
report.lastReadTimeby:setUnreadMarkerTimewithreadNewestActionbecause thereadNewestAction()function also updatesunreadMarkerTime:App/src/pages/home/report/ReportActionsList.tsx
Line 351 in ca1f4ff
I would prefer refactoring the whole logic to show the
unread markerbecause I think the code execution is pretty unpredictable right now. Refactoring it would ensure clean code and the desired behavior.64 remaining items
[-][$250] Chat - Unread marker displayed constantly on chat after keeping one duplicate expense.[/-][+][Due for payment 2025-05-27] [$250] Chat - Unread marker displayed constantly on chat after keeping one duplicate expense.[/+]melvin-bot commentedon May 20, 2025
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon May 20, 2025
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.46-12 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 2025-05-27. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon May 20, 2025
@Ollyws @adelekennedy @Ollyws The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
adelekennedy commentedon May 27, 2025
payment time!
Payment Summary
Contributor: @rohit9625 paid $250 via Upwork
Contributor+: @Ollyws due $250 via NewDot
Ollyws commentedon May 27, 2025
Requested in ND.
melvin-bot commentedon Jun 2, 2025
@adelekennedy Huh... This is 4 days overdue. Who can take care of this?
garrettmknight commentedon Jun 3, 2025
$250 approved for @Ollyws