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.56k stars 2.9k forks source link

[$250] Track expense - System message appears on wrong LHN report after changing merchant or desc #42858

Closed lanitochka17 closed 4 months ago

lanitochka17 commented 5 months 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: 1.4.77-3 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. Navigate to staging.new.expensify.com
  2. Open personal report
  3. Create a tracked expense
  4. Update either the description or the merchant of the tracked expense

Expected Result:

System message indicating merchant or description being updated gets displayed on LHN for the combined report of the tracked expense only

Actual Result:

System message indicating merchant or description being updated is shown on the LHN of the personal space report

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/Expensify/App/assets/78819774/b4b095fa-7c13-433e-b93e-d4955399a2e4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e89fac46add8bf9d
  • Upwork Job ID: 1797717388975722496
  • Last Price Increase: 2024-06-03
  • Automatic offers:
    • c3024 | Contributor | 102627885
Issue OwnerCurrent Issue Owner: @allroundexperts
melvin-bot[bot] commented 5 months ago

Triggered auto assignment to @johncschuster (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 5 months ago

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

lanitochka17 commented 5 months ago

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

c3024 commented 5 months ago

Proposal

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

System message (like changing of merchant) appears as subtitle of self DM in LHN. It should only appear as last message in the transaction thread and not in the selfDM in LHN.

What is the root cause of that problem?

This bug happens only when there is only one transaction in the self DM report. Here in OptionsListUtils https://github.com/Expensify/App/blob/0cb2dc052f01b6a024ac872ad8bf628159fe7873/src/libs/OptionsListUtils.ts#L291-L299 we merge the transaction thread report actions into IOU report actions if it is oneTransactionThreadReport so the last transaction of modified merchant is added into the report actions and set as the lastReportAction. In the present case of self DM, the lastMessage of modifying merchant appears on the LHN.

But this merging of transaction thread report actions for single transaction reports is not applicable for self DM because unlike other reports the tracked expenses are shown as separate report actions here instead of a single report preview merging all IOUs as shown in other reports.

Additionally, we don't see this report action of modifying merchant in the self DM report screen though the transaction report actions are added here as well https://github.com/Expensify/App/blob/0cb2dc052f01b6a024ac872ad8bf628159fe7873/src/pages/home/report/ReportActionsView.tsx#L160 with transactionThreadReportActions obtained from onyx with the transactionThreadReportID passed from ReportScreen https://github.com/Expensify/App/blob/0cb2dc052f01b6a024ac872ad8bf628159fe7873/src/pages/home/ReportScreen.tsx#L331-L334 This is because there is a check here when getting the getOneTransactionThreadReportID https://github.com/Expensify/App/blob/0cb2dc052f01b6a024ac872ad8bf628159fe7873/src/libs/ReportActionsUtils.ts#L878-L887 and it returns null when the skipReportTypeCheck is passed as false as seen here for track expenses because it is not one of the actions being checked there https://github.com/Expensify/App/blob/0cb2dc052f01b6a024ac872ad8bf628159fe7873/src/pages/home/ReportScreen.tsx#L332 whereas it is passed as true here https://github.com/Expensify/App/blob/0cb2dc052f01b6a024ac872ad8bf628159fe7873/src/libs/OptionsListUtils.ts#L293 which skips the check. If the check is not skipped it returns null and LHN shows correct message.

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

We can check if the report is self DM and pass the boolean here https://github.com/Expensify/App/blob/0cb2dc052f01b6a024ac872ad8bf628159fe7873/src/libs/OptionsListUtils.ts#L293 like

const isSelfDM = ReportUtils.isSelfDM(ReportUtils.getReport(reportID));

            // If the report is a one-transaction report and has , we need to return the combined reportActions so that the LHN can display modifications
            // to the transaction thread or the report itself
            const transactionThreadReportID = ReportActionUtils.getOneTransactionThreadReportID(reportID, actions[reportActions[0]], !isSelfDM);

What alternative solutions did you explore? (Optional)

I see this skip of check added here in #39472 for showing correct messages in LHN for edge cases. I changed the skipcheck to false in OptionsListUtils directly (irrespective of whether it is a self DM or not) and the tests succeeded fine. So, we might consider changing this https://github.com/Expensify/App/blob/0cb2dc052f01b6a024ac872ad8bf628159fe7873/src/libs/OptionsListUtils.ts#L293 simply to

const transactionThreadReportID = ReportActionUtils.getOneTransactionThreadReportID(reportID, actions[reportActions[0]], false);
melvin-bot[bot] commented 5 months ago

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

melvin-bot[bot] commented 5 months ago

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

allroundexperts commented 5 months ago

Reviewing today.

allroundexperts commented 5 months ago

@c3024's proposal looks good to me. I would suggest to go with the main proposal since its less likely to cause a regression.

πŸŽ€ πŸ‘€ πŸŽ€ C+ reviewed

melvin-bot[bot] commented 5 months ago

Triggered auto assignment to @NikkiWines, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

NikkiWines commented 5 months ago

I see this skip of check added here in https://github.com/Expensify/App/pull/39472 for showing correct messages in LHN for edge cases. I changed the skipcheck to false in OptionsListUtils directly (irrespective of whether it is a self DM or not) and the tests succeeded fine. So, we might consider changing this

I just double-checked this, and the behavior without the skipReportType check is fine for me as well. Even though I agree with @allroundexperts that it's more likely to cause regressions, I think we should use the alternative proposal, but go one step further and remove the skipReportTypeCheck altogether since it's apparently unnecessary now.

@allroundexperts @c3024 how does that sound to you?

c3024 commented 5 months ago

Yes, let's remove it. I don't think anything will be broken.

melvin-bot[bot] commented 5 months ago

πŸ“£ @c3024 πŸŽ‰ 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 πŸ“–

c3024 commented 5 months ago

@allroundexperts PR ready for review!

c3024 commented 5 months ago

@johncschuster This was deployed to production 4 days ago but automation failed here.

c3024 commented 4 months ago

@johncschuster Can you please complete the payment here? This was deployed to production 10 days ago. Thanks!

mallenexpensify commented 4 months ago

Contributor: @c3024 paid $250 via Upwork Contributor+: @allroundexperts due $250 via NewDot

@allroundexperts can you fill out the BZ checklist plzzzz

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:

melvin-bot[bot] commented 4 months ago

@johncschuster @NikkiWines @allroundexperts @c3024 this issue is now 4 weeks old, please consider:

Thanks!

allroundexperts commented 4 months ago

On to the checklist today.

allroundexperts commented 4 months ago

Checklist

  1. https://github.com/Expensify/App/pull/36934
  2. The PR author (@NikkiWines) is aware of the bug already.
  3. N/A
  4. A regression test would be helpful.

Regression test

  1. Login to any account and open the chat with yourself (personal report)
  2. Create a tracked expense
  3. Update either the description or the merchant of the tracked expense

Verify that the system message indicating merchant or description being updated gets displayed on LHN for the combined report of the tracked expense only.

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

mallenexpensify commented 4 months ago

Thanks @allroundexperts

JmillsExpensify commented 4 months ago

$250 approved for @allroundexperts