App icon indicating copy to clipboard operation
App copied to clipboard

[$250] Composer disappears and wrong error position when track distance to McTest offline

Open jponikarchuk opened this issue 2 months ago β€’ 33 comments

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: v9.2.45-1 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-1833/folder/13176744/47211684/996805372 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Device used: Lenovo 80ES / Windows 10 Pro App Component: Other

Action Performed:

  1. Create account with no workspace
  2. Go offline
  3. Go to FAB> Distance track> Map
  4. Complete the stops with random characters> Next
  5. Select Manager McTest from Chose recipient page> Create expense
  6. Go online

Expected Result:

Error message should be positioned into report section and chat composer should be displayed

Actual Result:

Error message "Unexpected error..." is displayed above expense report and chat composer is lost

Workaround:

Unknown

Platforms:

  • [ ] Android: App
  • [ ] Android: mWeb Chrome
  • [ ] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [ ] MacOS: Chrome / Safari
  • [ ] MacOS: Desktop

Screenshots/Videos

https://github.com/user-attachments/assets/bc1ceffe-edec-4a4e-a502-ee895985d8d2

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021986578186812285619
  • Upwork Job ID: 1986578186812285619
  • Last Price Increase: 2025-12-25
Issue OwnerCurrent Issue Owner: @aimane-chnaif

jponikarchuk avatar Nov 06 '25 05:11 jponikarchuk

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

melvin-bot[bot] avatar Nov 06 '25 05:11 melvin-bot[bot]

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

melvin-bot[bot] avatar Nov 06 '25 23:11 melvin-bot[bot]

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

melvin-bot[bot] avatar Nov 06 '25 23:11 melvin-bot[bot]

@IjaazA thanks for the proposal but I don't think your root cause is correct.

If you create offline distance request in already created DM, the issue doesn't happen.

Image

Unexpected error creating this chat - I think we should find why this happens.

aimane-chnaif avatar Nov 07 '25 17:11 aimane-chnaif

@aimane-chnaif Eep! 4 days overdue now. Issues have feelings too...

melvin-bot[bot] avatar Nov 12 '25 23:11 melvin-bot[bot]

Looking for proposals

aimane-chnaif avatar Nov 13 '25 13:11 aimane-chnaif

@aimane-chnaif I have updated my proposal , can you check now ?

IjaazA avatar Nov 13 '25 14:11 IjaazA

@IjaazA thanks. Have you ever tested your solution and confirmed it's working?

Looking for proposals

aimane-chnaif avatar Nov 13 '25 14:11 aimane-chnaif

πŸ“£ 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] avatar Nov 13 '25 16:11 melvin-bot[bot]

πŸ“£ 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] avatar Nov 20 '25 16:11 melvin-bot[bot]

@IjaazA just wondering if you've had a chance to look at @aimane-chnaif's Q on your proposal?

trjExpensify avatar Nov 24 '25 10:11 trjExpensify

Looks like contributor removed proposal as it's not working.

aimane-chnaif avatar Nov 24 '25 10:11 aimane-chnaif

Just found this issue. Taking a look.

TaduJR avatar Nov 24 '25 10:11 TaduJR

πŸ“£ 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] avatar Nov 27 '25 16:11 melvin-bot[bot]

@aimane-chnaif Whoops! This issue is 2 days overdue. Let's get this updated quick!

melvin-bot[bot] avatar Nov 28 '25 00:11 melvin-bot[bot]

@aimane-chnaif does it give to create with random locations on offline? It doesn't let me 🧐

Image

mukhrr avatar Nov 28 '25 01:11 mukhrr

@aimane-chnaif 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

melvin-bot[bot] avatar Dec 04 '25 00:12 melvin-bot[bot]

@mukhrr duplicate waypoints issue is fixed in #75829. We can continue.

aimane-chnaif avatar Dec 04 '25 02:12 aimane-chnaif

Proposal

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

When creating a distance request offline to Manager McTest (new DM), going online triggers an error but:

  1. The composer disappears
  2. The error shows in the wrong position (report header instead of expense preview)

What is the root cause of that problem?

When a money request fails, the client's failureData in buildOnyxDataForMoneyRequest sets errorFields.createChat on reports for any failure, but only when isNewChatReport is true:

https://github.com/Expensify/App/blob/938fac59abc30bc1bfc1b2a2ad8c2eda402397f3/src/libs/actions/IOU.ts#L2037-L2043

This causes two issues:

  1. Composer disappears: canUserPerformWriteAction checks for errorFields.createChat and returns false, hiding the composer:

https://github.com/Expensify/App/blob/938fac59abc30bc1bfc1b2a2ad8c2eda402397f3/src/libs/ReportUtils.ts#L7276-L7278

  1. Error in wrong position: The createChat error shows on the report header instead of the transaction. The actual API error (e.g., route/waypoint validation) is in response.onyxData on the transaction, but the generic createChat error takes precedence visually.

Why the issue doesn't happen with existing DM: The isNewChatReport condition is only true for new DMs (like Manager McTest on first contact). When creating a distance request in an already existing DM, isNewChatReport is false, so errorFields.createChat is never set in failureData, and the composer remains visible.

Additionally, TransactionPreviewContent has !isIOUSettled && shouldShowRBR which hides RBR on settled expenses - problematic when expense is optimistically "Paid" but API returns error:

https://github.com/Expensify/App/blob/938fac59abc30bc1bfc1b2a2ad8c2eda402397f3/src/components/ReportActionItem/TransactionPreview/TransactionPreviewContent.tsx#L371

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

1. Remove errorFields.createChat from failureData in IOU.ts

The API provides specific error data via response.onyxData (transaction errors). Setting createChat error incorrectly blocks the composer and shows generic error.

https://github.com/Expensify/App/blob/938fac59abc30bc1bfc1b2a2ad8c2eda402397f3/src/libs/actions/IOU.ts#L2037-L2043

Remove the errorFields.createChat spread for chat report, IOU report, and transaction thread report.

2. Add hasTransactionErrors to shouldShowRBR in TransactionPreviewUtils.ts

https://github.com/Expensify/App/blob/938fac59abc30bc1bfc1b2a2ad8c2eda402397f3/src/libs/TransactionPreviewUtils.ts#L414

+    const hasTransactionErrors = !isEmptyObject(transaction?.errors) || !isEmptyObject(transaction?.errorFields?.route) || !isEmptyObject(transaction?.errorFields?.waypoints);
-    const shouldShowRBR = hasAnyViolations || hasErrorOrOnHold || hasReportViolationsOrActionErrors || hasReceiptError(transaction);
+    const shouldShowRBR = hasAnyViolations || hasErrorOrOnHold || hasReportViolationsOrActionErrors || hasReceiptError(transaction) || hasTransactionErrors;

3. Add RBRMessage extraction from transaction errors in TransactionPreviewUtils.ts

https://github.com/Expensify/App/blob/938fac59abc30bc1bfc1b2a2ad8c2eda402397f3/src/libs/TransactionPreviewUtils.ts#L275

+    const transactionErrorMessage = getLatestErrorMessage(transaction) || Object.values(getLatestErrorFieldForAnyField(transaction)).at(0);
+    if (!RBRMessage && transactionErrorMessage) {
+        RBRMessage = {text: transactionErrorMessage};
+    }

4. Remove !isIOUSettled from RBR display in TransactionPreviewContent.tsx

https://github.com/Expensify/App/blob/938fac59abc30bc1bfc1b2a2ad8c2eda402397f3/src/components/ReportActionItem/TransactionPreview/TransactionPreviewContent.tsx#L371

-    {!isIOUSettled && shouldShowRBR && (
+    {shouldShowRBR && (

The !isIOUSettled check was intended to hide validation errors (like missing fields) on settled expenses since they're no longer actionable. However, the shouldShowRBR calculation already handles this appropriately - the hasErrorOrOnHold condition already filters out "on hold" status for settled expenses:

https://github.com/Expensify/App/blob/938fac59abc30bc1bfc1b2a2ad8c2eda402397f3/src/libs/TransactionPreviewUtils.ts#L412

For API submission errors (our case), we must show the error regardless of settlement status because the expense was optimistically marked "Paid" before the API returned an error - the user needs to see it failed.

TaduJR avatar Dec 04 '25 05:12 TaduJR

πŸ“£ 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] avatar Dec 04 '25 16:12 melvin-bot[bot]

@trjExpensify @aimane-chnaif this issue is now 4 weeks old, please consider:

  • Finding a contributor to fix the bug
  • Closing the issue if BZ has been unable to add the issue to a VIP or Wave project
  • If you have any questions, don't hesitate to start a discussion in #expensify-open-source

Thanks!

melvin-bot[bot] avatar Dec 04 '25 22:12 melvin-bot[bot]

@aimane-chnaif Huh... This is 4 days overdue. Who can take care of this?

melvin-bot[bot] avatar Dec 09 '25 23:12 melvin-bot[bot]

@TaduJR can you please share demo video?

aimane-chnaif avatar Dec 11 '25 06:12 aimane-chnaif

πŸ“£ 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] avatar Dec 11 '25 16:12 melvin-bot[bot]

@TaduJR can you please share demo video?

Here @aimane-chnaif

https://github.com/user-attachments/assets/51d0d7e1-a0b0-4bfe-9785-9f279c8a2717

TaduJR avatar Dec 12 '25 14:12 TaduJR

@aimane-chnaif Eep! 4 days overdue now. Issues have feelings too...

melvin-bot[bot] avatar Dec 16 '25 23:12 melvin-bot[bot]

πŸ“£ 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] avatar Dec 18 '25 16:12 melvin-bot[bot]

@aimane-chnaif 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

melvin-bot[bot] avatar Dec 18 '25 23:12 melvin-bot[bot]

@TaduJR are you able to reproduce on latest main?

aimane-chnaif avatar Dec 19 '25 15:12 aimane-chnaif

Able to repo on staging @aimane-chnaif

Image

TaduJR avatar Dec 19 '25 15:12 TaduJR