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.36k stars 2.79k forks source link

[HOLD for payment 2024-08-19] [$250] Track expense - App throws error when submitting track distance expense #47042

Closed IuliiaHerets closed 1 month ago

IuliiaHerets 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: v9.0.18-1 Reproducible in staging?: Y Reproducible in production?: N Email or phone of affected tester (no customers): applausetester+kh050806@applause.expensifail.com Issue reported by: Applause Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to self DM.
  3. Click + > Track expense > Distance.
  4. Submit a track distance expense.

Expected Result:

The track distance expense will be created successfully.

Actual Result:

App throws error when submitting track distance expense - There is a previously existing chat between these users.

Workaround:

Uncnown

Platforms:

Which of our officially supported platforms is this issue occurring on?

Screenshots/Videos

https://github.com/user-attachments/assets/a931bfe2-a93e-44a0-8554-79800bbba54f

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~018888d22189418e67
  • Upwork Job ID: 1821495281651751011
  • Last Price Increase: 2024-08-08
  • Automatic offers:
    • jjcoffee | Reviewer | 103448882
    • dominictb | Contributor | 103448883
Issue OwnerCurrent Issue Owner: @stephanieelliott
melvin-bot[bot] commented 1 month ago

Triggered auto assignment to @stephanieelliott (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] commented 1 month ago

Triggered auto assignment to @pecanoro (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

github-actions[bot] commented 1 month ago

:wave: Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.
IuliiaHerets commented 1 month ago

We think that this bug might be related to #vip-vsb

pecanoro commented 1 month ago

I can reproduce but if it's not coming from the back-end, I am wondering if we changed the API request in some PR, looking!

image

pecanoro commented 1 month ago

Oh, on production we call TrackExpense and we call CreateDistanceRequest on staging

image

image

pecanoro commented 1 month ago

It's coming from this PR: https://github.com/Expensify/App/pull/42302

pecanoro commented 1 month ago

I am going to open it for proposals since everyone involved in the original PR is not online and if we don't get any, I will revert the original PR.

melvin-bot[bot] commented 1 month ago

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

melvin-bot[bot] commented 1 month ago

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

dominictb commented 1 month ago

Edited by proposal-police: This proposal was edited at 2024-08-08 11:42:06 UTC.

@pecanoro I can raise the PR asap to fix this

Proposal

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

App throws error when submitting track distance expense - There is a previously existing chat between these users.

What is the root cause of that problem?

In the PR https://github.com/Expensify/App/pull/42302, we mistakenly moved the createDistanceRequest(iouType == condition to the top (this change https://github.com/Expensify/App/pull/42302/files#diff-5e5fc302dd5db871d26e30f810bc0606beccb7f50ae6ed6535cd93aaee98c280), causing it to be evaluated first and not trackExpense, so it calls CreateDistanceRequest in track distance expense case instead of TrackExpense

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

Move this block back to its correct location before the PR which is here https://github.com/Expensify/App/blob/0926267c22e50e68b52c055dacc3af775235ccd4/src/pages/iou/request/step/IOURequestStepConfirmation.tsx#L505

What alternative solutions did you explore? (Optional)

Update this block to

if (iouType !== CONST.IOU.TYPE.TRACK && isDistanceRequest && !isMovingTransactionFromTrackExpense) {
                createDistanceRequest(iouType === CONST.IOU.TYPE.SPLIT ? splitParticipants : selectedParticipants, trimmedComment);
                return;
            }

So it will only createDistanceRequest if it's not a track expense, we can extend the iouType check for other iou types if needed (if there're other IOU types that should not call createDistanceRequest but uses its own method, like track expense)

dominictb commented 1 month ago

Proposal updated to add alternative approach

jjcoffee commented 1 month ago

Hmm, I don't think we can just move createDistanceRequest back down as that would most likely cause a regression from https://github.com/Expensify/App/pull/42302 since we'd call IOU.splitBill first and return early instead of creating the distance request for splitting.

~I wonder if we also need to handle~ !isMovingTransactionFromTrackExpense covers the other conditions that result in calling trackExpense:

https://github.com/Expensify/App/blob/717d344a38bb04265d219a5143d6ab0dd70596ed/src/pages/iou/request/step/IOURequestStepConfirmation.tsx#L446

jjcoffee commented 1 month ago

Having investigated further, it looks like @dominictb's alternative solution is the way to go here.

:ribbon::eyes::ribbon: C+ reviewed

melvin-bot[bot] commented 1 month ago

Current assignee @pecanoro is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

dominictb commented 1 month ago

Thanks @jjcoffee for the review, @pecanoro Can you assign me to the issue so I can raise the PR asap?

pecanoro commented 1 month ago

Sounds good, assigning @dominictb

melvin-bot[bot] commented 1 month ago

πŸ“£ @jjcoffee πŸŽ‰ An offer has been automatically sent to your Upwork account for the Reviewer role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job

melvin-bot[bot] commented 1 month ago

πŸ“£ @dominictb πŸŽ‰ An offer has been automatically sent to your Upwork account for the Contributor role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review πŸ§‘β€πŸ’» Keep in mind: Code of Conduct | Contributing πŸ“–

dominictb commented 1 month ago

Thanks πŸ™ On it now

dominictb commented 1 month ago

@jjcoffee The PR is ready.

mvtglobally commented 1 month ago

Looks resolved

https://github.com/user-attachments/assets/8cba050b-ab46-4db8-bcc9-d2b19b03ca67

pecanoro commented 1 month ago

Awesome, thank you! Removing deploy blocker

melvin-bot[bot] commented 1 month ago

Reviewing label has been removed, please complete the "BugZero Checklist".

melvin-bot[bot] commented 1 month ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 9.0.18-10 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-08-19. :confetti_ball:

For reference, here are some details about the assignees on this issue:

melvin-bot[bot] commented 1 month ago

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

stephanieelliott commented 1 month ago

Summarizing payment on this issue:

stephanieelliott commented 1 month ago

Hey @jjcoffee can you please complete the BZ checklist for this when you get a sec?

jjcoffee commented 1 month ago

Regression Test Proposal

  1. Go to self DM.
  2. Click + > Track expense > Distance.
  3. Submit a track distance expense.
  4. Verify that the expense shows up with no errors.

Do we agree πŸ‘ or πŸ‘Ž

stephanieelliott commented 1 month ago

Test case created! https://github.com/Expensify/Expensify/issues/422130

All done here, thanks!