[HOLD for payment 2024-12-03] [$250] Chat - Unread marker briefly displayed when submitting expense via FAB
If you havenโt already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 9.0.62-0 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Issue reported by: Applause - Internal Team
Action Performed:
- Open the Expensify app
- Tap on the FAB and select "Create Expense"
- Complete the expense creation flow and send the expense to any workspace
- Verify the expense preview is correctly displayed on chat and that no green line is displayed above the expense
Expected Result:
Unread marker shouldnยดt appear above an expense when the user finishes the creation flow and lands on chat
Actual Result:
After the user finishes the expense creation flow, started via FAB, and lands on chat, an unread marker can be seen for some seconds above the just created expense
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
- [x] Android: Standalone
- [x] Android: HybridApp
- [x] Android: mWeb Chrome
- [ ] iOS: Standalone
- [ ] iOS: HybridApp
- [ ] iOS: mWeb Safari
- [ ] MacOS: Chrome / Safari
- [ ] MacOS: Desktop
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/user-attachments/assets/3b138e85-55ac-46aa-9bd0-5f3e71a91712
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~021857472707590021857
- Upwork Job ID: 1857472707590021857
- Last Price Increase: 2024-11-15
- Automatic offers:
- c3024 | Reviewer | 104971519
Issue Owner
Current Issue Owner: @garrettmknight
Triggered auto assignment to @garrettmknight (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.
Proposal
Please re-state the problem that we are trying to solve in this issue.
After the user finishes the expense creation flow, started via FAB, and lands on chat, an unread marker can be seen for some seconds above the just created expense
What is the root cause of that problem?
After request money, we update the lastReadTime in
https://github.com/Expensify/App/blob/d5a7b499d3ba2074f5ad069ed27a043d029d7036/src/libs/actions/IOU.ts#L3663
when navigate to report, lastReadTime at that time has not been updated yet in Onyx so it's less than the newest action's created time
then isCurrentMessageUnread is true
That why we see the unread marker
After RequestMoney API calls successfully, all data is correct so the unread marker disappear
What changes do you think we should make in order to solve the problem?
We should update lastReadTime in here
ReportConnection.updateReportData(report?.reportID ?? '', {
lastReadTime: DateUtils.getDBTime(),
});
What alternative solutions did you explore? (Optional)
NA
Proposal
Please re-state the problem that we are trying to solve in this issue.
The new report preview is marked as unread when we create a new expense.
What is the root cause of that problem?
When we create a new expense, it will optimistically create a new report preview and update the chat report lastReadTime.
The unread marker will show if the unreadMarkerTime which is a state that contains the lastReadTime is smaller than the action created time.
https://github.com/Expensify/App/blob/a6f1348d08a441f4f9b48a8ef05e5e95c96b53d7/src/pages/home/report/ReportActionsList.tsx#L276
https://github.com/Expensify/App/blob/a6f1348d08a441f4f9b48a8ef05e5e95c96b53d7/src/libs/ReportActionsUtils.ts#L1457-L1463
Based on the optimistic data, the lastReadTime is bigger than the report preview action created time, but when the workspace chat is opened, the lastReadTime isn't updated yet, so unreadMarkerTime state will contains the previous lastReadTime.
https://github.com/Expensify/App/blob/a6f1348d08a441f4f9b48a8ef05e5e95c96b53d7/src/pages/home/report/ReportActionsList.tsx#L220
When the new report preview action arrives, the unread marker shows. We already have a fix for this kind of issue where we won't show the unread marker for the current user action if it's a new action or if it's previously an optimistic action. https://github.com/Expensify/App/blob/a6f1348d08a441f4f9b48a8ef05e5e95c96b53d7/src/pages/home/report/ReportActionsList.tsx#L287-L294
However, the isFromCurrentUser currently returns false for report preview action.
https://github.com/Expensify/App/blob/a6f1348d08a441f4f9b48a8ef05e5e95c96b53d7/src/pages/home/report/ReportActionsList.tsx#L284
There are 2 issues. First, we are comparing the current user accountID with a boolean (!message.childLastActorAccountID).
Second, we don't set the childLastActorAccountID optimistically, so it's always undefined.
What changes do you think we should make in order to solve the problem?
Remove ! from message.childLastActorAccountID. Then, optimistically set the childLastActorAccountID to the current user.
https://github.com/Expensify/App/blob/a6f1348d08a441f4f9b48a8ef05e5e95c96b53d7/src/libs/ReportUtils.ts#L5140-L5177
childLastActorAccountID: currentUserAccountID,
The BE response return the current user as the childLastActorAccountID.
Job added to Upwork: https://www.upwork.com/jobs/~021857472707590021857
Triggered auto assignment to Contributor-plus team member for initial proposal review - @c3024 (External)
@garrettmknight, @c3024 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
Thank you for your proposals.
@bernhardoj 's RCA makes sense and the suggested fix in his proposal LGTM!
๐ ๐ ๐ C+ reviewed.
Triggered auto assignment to @dangrous, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
oh that boolean thing is weird! @bernhardoj's fix sounds good to me!
๐ฃ @c3024 ๐ An offer has been automatically sent to your Upwork account for the Reviewer role ๐ Thanks for contributing to the Expensify app!
PR is ready
cc: @c3024
Reviewing label has been removed, please complete the "BugZero Checklist".
The solution for this issue has been :rocket: deployed to production :rocket: in version 9.0.66-8 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:
- https://github.com/Expensify/App/pull/52811
If no regressions arise, payment will be issued on 2024-12-03. :confetti_ball:
For reference, here are some details about the assignees on this issue:
- @bernhardoj requires payment through NewDot Manual Requests
- @c3024 requires payment automatic offer (Reviewer)
@c3024 @garrettmknight @c3024 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]
@bernhardoj go ahead and submit for payment. @c3024 please complete the checklist.
Payment Summary:
- Contributor: @bernhardoj $250 via newdot
- Contributor+: @c3024 $250 via upwork
Requested in ND.
$250 approved for @bernhardoj
BugZero Checklist:
- [x] [Contributor] Classify the bug:
Bug classification
Source of bug:
- [ ] 1a. Result of the original design (eg. a case wasn't considered)
- [x] 1b. Mistake during implementation
- [ ] 1c. Backend bug
- [ ] 1z. Other:
Where bug was reported:
- [x] 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
- [ ] 2b. Reported on staging (eg. found during regression or PR testing)
- [ ] 2d. Reported on a PR
- [ ] 2z. Other:
Who reported the bug:
- [ ] 3a. Expensify user
- [ ] 3b. Expensify employee
- [ ] 3c. Contributor
- [x] 3d. QA
- [ ] 3z. Other:
-
[x] [Contributor] 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: https://github.com/Expensify/App/commit/9c4344c3d444628e0c5d41eee2ca289c31a2a27f#r150024277
-
[x] [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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: No discussion was started because this could not be identified earlier.
-
[x] [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
-
[ ] [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Precondition:
- None
Test:
- Submit a new money request to a workspace chat that has no unsettled expenses.
- Verify that there is no new message marker above the new report preview.
Do we agree ๐ or ๐
All done and paid up.