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.27k stars 2.71k forks source link

[$250] Search - Expense shows From User B to User A when User A pays User B (pay someone) #45611

Closed lanitochka17 closed 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.8-1 Reproducible in staging?: Y Reproducible in production?: 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:

  1. Go to staging.new.expensify.com
  2. Go to DM with any user
  3. Click + > Pay [X email]
  4. Enter amount and pay the user
  5. Go to Search
  6. Look for the payment sent in Step 4

Expected Result:

The expense should display "From User A to User B"

Actual Result:

The expense displays "From User B to User A", where User B is the receiver and User A is the payer.

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/28634f64-536c-4db0-bb6d-a0d565289f2b

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01bcec74253fa9dcd4
  • Upwork Job ID: 1813632166397470742
  • Last Price Increase: 2024-07-17
Issue OwnerCurrent Issue Owner: @luacmartins
melvin-bot[bot] commented 1 month ago

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

@Christinadobrzyn 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

Christinadobrzyn commented 1 month ago

Oh yeah this is a good catch - I think it's part of Wave- Collect. I'm not sure if this needs to be internal but let's start external.

melvin-bot[bot] commented 1 month ago

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

melvin-bot[bot] commented 1 month ago

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

tufcoder commented 1 month ago

Proposal

Please rewrite the problem we are trying to solve in this question.

The expense displays “From user B to user A”, where user B is the receiver and user A is the payer.

What is the root cause of this problem?

The video attached to this Issue does not match the problem mentioned, but following what is written in “Action Performed” I believe I have reproduced the problem.

The ParentNavigationSubtitle.tsx component is rendering the content using the translate() function, passing the 'threads.from' string as a parameter.

If this is not the problem, I apologize for the misinterpretation.

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

I suggest making an addition to threads in the file src/languages/en.ts to include the to option.

threads: {
         to: 'To',
         ...
},

This way, we can use ...translate('threads.to') in the ParentNavigationSubtitle.tsx component to render the content correctly.

The updated content is shown below:

image

image

melvin-bot[bot] commented 1 month ago

📣 @tufcoder! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
tufcoder commented 1 month ago

Contributor details Your Expensify account email: oswaldogpc@gmail.com Upwork Profile Link: https://www.upwork.com/freelancers/~01f8fa45648f96ad67

melvin-bot[bot] commented 1 month ago

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

dominictb commented 1 month ago

Proposal

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

The expense displays "From User B to User A", where User B is the receiver and User A is the payer.

What is the root cause of that problem?

In case of Pay someone, in here, the user of transactionItem.managerID is the one who send the money, and user of transactionItem.accountID is the receiver. Hence the issue.

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

In general, we can assume that in case the transaction is IOU type:

Hence, in this case, we want to swap the formattedFrom and formattedTo in here.

  const isIOUReport = transactionItem.reportType === CONST.REPORT.TYPE.IOU;
  let formattedFrom = from?.displayName ?? from?.login ?? '';
    let formattedTo = to?.name ?? to?.displayName ?? to?.login ?? '';

    if(isIOUReport && (transactionItem?.modifiedAmount || transactionItem.amount) > 0) {
        [formattedFrom, formattedTo] = [formattedTo, formattedFrom];
    }

What alternative solutions did you explore? (Optional)

NA

Christinadobrzyn commented 1 month ago

Hi @rojiphil can you review these proposals when you have a moment? TY!

tufcoder commented 1 month ago

Please disregard my proposal because it is not in line with the problem.

trjExpensify commented 1 month ago

@luacmartins for vis on this one.

Christinadobrzyn commented 1 month ago

@rojiphil can you take a peek at this proposal thank you! - https://github.com/Expensify/App/issues/45611#issuecomment-2236415812

rojiphil commented 1 month ago

Reviewing today

luacmartins commented 1 month ago

I think @dominictb has the correct RCA, but IMO this should be fixed on the server so we send the correct values to the client and there's no need for further data manipulation.

luacmartins commented 1 month ago

Hmm we already have similar logic in the backend, but I'm not sure that comparing just reportType and amounts is enough. I wonder if we also need to check if this is a Send money request or not. cc @mountiny do you know?

mountiny commented 1 month ago

Yeah thats fair @luacmartins I think we could add check for the IOUDetails in message to confirm its Send money flow

luacmartins commented 1 month ago

@mountiny so it's not enough to compare the report type and amount sign for the paid case, right? We also need to identify that the request type for send?

mountiny commented 1 month ago

yeah I think that we ideally check for the type=pay && IOUDetails.size() like here wherever we need to catch the send money flow

melvin-bot[bot] commented 1 month ago

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

luacmartins commented 1 month ago

PR in review

Christinadobrzyn commented 1 month ago

The PR looks like it's been deployed already! Wow! I'll keep an eye out for the payment automessage

luacmartins commented 1 month ago

This issue was worked on internally. Not sure if there's any payment due here.

rojiphil commented 1 month ago

Not sure if there's any payment due here.

yea... no payment for me here

Christinadobrzyn commented 1 month ago

Oh perfect, thanks for confirming. Since there are no payments - Do you want me to just close this out now or wait for the 7-day window @luacmartins?

luacmartins commented 1 month ago

Thanks for asking! We can close this out, since the backend PR was deployed and the issue is fixed.