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.55k stars 2.89k forks source link

[$250] IOS-Distance - Expense details blank after creating distance expense offline and going online #50589

Open lanitochka17 opened 1 month ago

lanitochka17 commented 1 month 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.47-2 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5070301 Issue reported by: Applause - Internal Team

Action Performed:

  1. Open the app and log in
  2. Create a workspace if needed
  3. Navigate to the workspace chat
  4. Disable the internet connection
  5. Create a distance expense
  6. Open the transaction details
  7. Return online

Expected Result:

The expense details are still displayed when user is returning online and updated with the correct values

Actual Result:

The expense details get blank when returning online. It requires to swipe down if there is just 1 expense in the report, or they appear after the distance gets calculated

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/5977a467-b4d0-4df6-ac9b-0d9dbbd60b0e

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021844782851274386137
  • Upwork Job ID: 1844782851274386137
  • Last Price Increase: 2024-11-08
Issue OwnerCurrent Issue Owner: @c3024
melvin-bot[bot] commented 1 month ago

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

lanitochka17 commented 1 month ago

@isabelastisser FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

lanitochka17 commented 1 month ago

We think that this bug might be related to #wave-collect - Release 1

huult commented 1 month ago

Proposal

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

Expense details blank after creating distance expense offline and going online

What is the root cause of that problem?

This issue occurs because shouldEnableAutoScroll returns false, preventing the scroll from reaching the bottom when coming back online after new data is updated

shouldEnableAutoScroll returns false because hasNewestReportAction also returns false. This occurs because the condition reportActions.at(0)?.created === report.lastVisibleActionCreated fails, as the created and lastVisibleActionCreated values are different after the previous logic is applied, and the backend does not respond with created and lastVisibleActionCreated at the same time, so they are different by about under 10 ms

Log example:

 LOG  ****** reportActions.at(0)?.created ****** 2024-10-11 14:55:54.928
 LOG  ****** report.lastVisibleActionCreated ****** 2024-10-11 14:55:54.932

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

We need the backend to update the condition so that created and lastVisibleActionCreated return at the same time. If not, we need to add a buffer time for this condition. Some thing like this:

//.src/pages/home/report/ReportActionsView.tsx#L289
-         const hasNewestReportAction = reportActions.at(0)?.created === report.lastVisibleActionCreated || reportActions.at(0)?.created === transactionThreadReport?.lastVisibleActionCreated;
+     const bufferTime = 10; // Buffer time in milliseconds

+    const firstReportActionCreated = reportActions?.[0]?.created;
+    const lastVisibleActionCreated = report.lastVisibleActionCreated || transactionThreadReport?.lastVisibleActionCreated;

+    const hasNewestReportAction =
+        firstReportActionCreated && lastVisibleActionCreated
+            ? Math.abs(new Date(firstReportActionCreated).getTime() - new Date(lastVisibleActionCreated).getTime()) <= bufferTime
+            : firstReportActionCreated === report.lastVisibleActionCreated || firstReportActionCreated === transactionThreadReport?.lastVisibleActionCreated;
POC https://github.com/user-attachments/assets/39168697-6aa3-4d0a-b518-040b124f05c4
melvin-bot[bot] commented 1 month ago

Job added to Upwork: https://www.upwork.com/jobs/~021844782851274386137

melvin-bot[bot] commented 1 month ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @c3024 (External)

melvin-bot[bot] commented 1 month ago

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

c3024 commented 4 weeks ago

This seems to happen only on iOS app and not on iOS mWeb. Perhaps, this requires a more specific solution related to code in some native or ios files?

melvin-bot[bot] commented 3 weeks ago

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

c3024 commented 3 weeks ago

@huult

Thanks for the proposal. Why does this happen only on iOS?

huult commented 3 weeks ago

@c3024 , this issue was fixed by another pull request, which same with my idea

c3024 commented 3 weeks ago

Oh, thanks!

@isabelastisser

This issue can be closed.

lanitochka17 commented 2 weeks ago

Issue is still reproducible on the latest build on Hybrid and standalone

https://github.com/user-attachments/assets/2b16fbbd-31f0-4f34-a9e3-1572d125ff0e

https://github.com/user-attachments/assets/a23632ce-0c35-4da9-8832-7a82164fc11a

melvin-bot[bot] commented 2 weeks ago

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

isabelastisser commented 2 weeks ago

Waiting for proposals!

c3024 commented 2 weeks ago

Waiting for proposals!

melvin-bot[bot] commented 1 week ago

@isabelastisser, @c3024 Whoops! This issue is 2 days overdue. Let's get this updated quick!

c3024 commented 1 week ago

Waiting for proposals!

melvin-bot[bot] commented 1 week ago

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

melvin-bot[bot] commented 1 week ago

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

isabelastisser commented 1 week ago

No proposals yet.

c3024 commented 1 week ago

Waiting for proposals!

melvin-bot[bot] commented 5 days ago

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

c3024 commented 5 days ago

Waiting for proposals!

melvin-bot[bot] commented 1 day ago

@isabelastisser, @c3024 Whoops! This issue is 2 days overdue. Let's get this updated quick!

c3024 commented 1 day ago

Waiting for proposals!