Expensify: Fix Unread Chat Expenses Bug In Workspace
Hey guys! 👋 We've got a bug report here detailing an issue with Expensify where expenses in a workspace keep showing up in the Unread chats, even after they've been opened. Let's dive into the details and see what's going on.
Issue Overview
The main problem is that after you open the details of a workspace expense, and then create subsequent expenses, these new expenses continue to appear in the Unread section of Reports/Chats, even though they should be marked as read.
This can be pretty annoying because it messes with your workflow, making it hard to keep track of what actually needs your attention. Imagine opening an expense, dealing with it, and then having it pop up again as if you haven't seen it. Nobody wants that!
Version Number: 9.1.98-0
Reproducibility: This issue is happening in both staging and production environments, so it's definitely something we need to address ASAP.
Regression Testing: It was caught during regression testing. You can check out the test case here: https://test-management.browserstack.com/projects/2219752/folder/13176922/test-cases/41237507
Reported by: Applause Internal Team
Devices Used:
- MacBook Air 15.6 Chrome
- iPhone 15 iOS 18.6 Safari
App Component: Search
Steps to Reproduce
Here’s how you can reproduce this bug:
- Create a New Account: Start by signing into ND with a brand new account.
- Set Up a Workspace: Go ahead and create a workspace.
- First Expense: Manually create an expense within the workspace chat. Then, open the details page for this expense.
- Second Expense: Navigate back to the chat and create another expense.
- Check the Report: Open the report, then open the details of this newly created expense.
- Back to Chat: Go back to the workspace chat again.
- Filter by Unread: Navigate to the reports tab or Chats, click on the Status filter, and select “Unread.”
- Re-Open Expense Details: Open the expense details again from the Reports tab.
- Repeat: Keep repeating step 7 to see the issue persist.
Expected Result
Opened expenses should not be shown in the Reports/Chats/Unread section. Once you've opened and viewed an expense, it should be marked as read and disappear from the Unread filter.
Actual Result
Opened workspace expenses are incorrectly shown in the Reports/Chats/Unread section. This means expenses you've already seen keep popping up, causing confusion and making it harder to manage your expenses. Imagine the chaos if every expense you've ever opened kept showing up as unread – total madness!
Platforms Affected
This bug is hitting users across various platforms:
- [x] Android: App
- [x] Android: mWeb Chrome
- [x] iOS: App
- [x] iOS: mWeb Safari
- [x] iOS: mWeb Chrome
- [x] Windows: Chrome
- [x] MacOS: Chrome / Safari
- [x] MacOS: Desktop
Essentially, no one is safe from this issue, regardless of their device or browser.
Detailed Analysis
Understanding the Root Cause
To really nail down what's happening here, we need to understand how Expensify tracks the read/unread status of expenses within a workspace context. It seems like the system isn't properly updating the status after the initial viewing, especially when new expenses are introduced. Here’s a breakdown of potential problem areas:
- Status Flag Inconsistency: There might be an issue with how the "read" status flag is being set or updated in the database. It’s possible that the flag isn’t being flipped correctly after the user opens the expense details, or that it's being reset when a new expense is created.
- Caching Issues: Caching could be playing a role. If the app is aggressively caching the unread status, it might not be refreshing the view when new expenses are added. This would explain why previously opened expenses keep reappearing in the Unread section.
- Event Handling Problems: The event handling mechanism, which is responsible for marking expenses as read, might not be firing correctly. This could be due to a race condition or some other asynchronous issue that prevents the status from being updated in real-time.
- Workspace Context Confusion: The app might be struggling to maintain the correct context within the workspace. When new expenses are created, the app might be losing track of which expenses have already been viewed, leading to the re-emergence of opened expenses in the Unread section.
Impact Assessment
The impact of this bug is more than just a minor annoyance. It affects user productivity and overall experience in several ways:
- Reduced Efficiency: Users have to spend extra time sorting through expenses they've already seen, which slows down their workflow.
- Increased Frustration: Constantly seeing the same expenses marked as unread can be incredibly frustrating, especially for users who manage a high volume of expenses.
- Potential for Errors: The confusion caused by this bug could lead to users accidentally missing new, genuinely unread expenses.
Possible Solutions
Here are a few approaches we could take to fix this issue:
- Database Audit: Conduct a thorough audit of the database schema and the queries used to update the read status of expenses. Ensure that the status flag is being updated correctly and consistently.
- Cache Management: Implement a more robust cache invalidation strategy. When a user opens an expense, immediately invalidate the relevant cache entries to force a refresh of the Unread section.
- Event Handling Review: Review the event handling mechanism to ensure that the events for marking expenses as read are being fired and handled correctly. Use debugging tools to trace the flow of events and identify any potential bottlenecks.
- Contextual Awareness: Improve the app's ability to maintain context within the workspace. Implement better session management to ensure that the app always knows which expenses have been viewed by the user.
Workaround
Unfortunately, there’s currently no known workaround for this issue. Users will have to manually filter through their expenses to identify the ones they haven’t seen yet.
Screenshots/Videos
https://github.com/user-attachments/assets/63b3f85e-2447-4892-9ed7-de83233374b9
Contributing
If you're interested in helping out, check out the contributing guidelines and email [email protected] to join our Slack channel! We'd love to have you on board.