Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 of 6 tasks
lanitochka17 opened this issue May 30, 2024 · 21 comments
Closed
1 of 6 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented May 30, 2024

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?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6495857_1717054028787.bandicam_2024-05-30_10-20-30-005.mp4

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
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 30, 2024
Copy link

melvin-bot bot commented May 30, 2024

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
Copy link
Author

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

@lanitochka17
Copy link
Author

@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
Copy link
Contributor

c3024 commented Jun 1, 2024

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

// 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]], true);
if (transactionThreadReportID) {
const transactionThreadReportActionsArray = Object.values(actions[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`] ?? {});
sortedReportActions = ReportActionUtils.getCombinedReportActions(reportActionsArray, transactionThreadReportActionsArray, reportID);
}
lastReportActions[reportID] = sortedReportActions[0];

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

() => ReportActionsUtils.getCombinedReportActions(allReportActions, transactionThreadReportActions),

with transactionThreadReportActions obtained from onyx with the transactionThreadReportID passed from ReportScreen
const transactionThreadReportID = useMemo(
() => ReportActionsUtils.getOneTransactionThreadReportID(report.reportID, reportActions ?? [], false, isOffline),
[report.reportID, reportActions, isOffline],
);

This is because there is a check here when getting the getOneTransactionThreadReportID
skipReportTypeCheck: boolean | undefined = undefined,
isOffline: boolean | undefined = undefined,
): string | null {
if (!skipReportTypeCheck) {
// If the report is not an IOU, Expense report, or Invoice, it shouldn't be treated as one-transaction report.
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
if (report?.type !== CONST.REPORT.TYPE.IOU && report?.type !== CONST.REPORT.TYPE.EXPENSE && report?.type !== CONST.REPORT.TYPE.INVOICE) {
return null;
}
}

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
() => ReportActionsUtils.getOneTransactionThreadReportID(report.reportID, reportActions ?? [], false, isOffline),

whereas it is passed as true here
const transactionThreadReportID = ReportActionUtils.getOneTransactionThreadReportID(reportID, actions[reportActions[0]], true);

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

const transactionThreadReportID = ReportActionUtils.getOneTransactionThreadReportID(reportID, actions[reportActions[0]], true);

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

const transactionThreadReportID = ReportActionUtils.getOneTransactionThreadReportID(reportID, actions[reportActions[0]], true);

simply to

const transactionThreadReportID = ReportActionUtils.getOneTransactionThreadReportID(reportID, actions[reportActions[0]], false);

@melvin-bot melvin-bot bot added the Overdue label Jun 3, 2024
@johncschuster johncschuster added the External Added to denote the issue can be worked on by a contributor label Jun 3, 2024
@melvin-bot melvin-bot bot changed the title Track expense - System message appears on wrong LHN report after changing merchant or desc [$250] Track expense - System message appears on wrong LHN report after changing merchant or desc Jun 3, 2024
Copy link

melvin-bot bot commented Jun 3, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 3, 2024
Copy link

melvin-bot bot commented Jun 3, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Jun 3, 2024
@allroundexperts
Copy link
Contributor

Reviewing today.

@allroundexperts
Copy link
Contributor

@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

Copy link

melvin-bot bot commented Jun 4, 2024

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

@NikkiWines
Copy link
Contributor

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

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
Copy link
Contributor

c3024 commented Jun 6, 2024

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

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 6, 2024
Copy link

melvin-bot bot commented Jun 6, 2024

📣 @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
Copy link
Contributor

c3024 commented Jun 7, 2024

@allroundexperts PR ready for review!

@c3024
Copy link
Contributor

c3024 commented Jun 18, 2024

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

@c3024
Copy link
Contributor

c3024 commented Jun 25, 2024

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

@mallenexpensify mallenexpensify removed the Reviewing Has a PR in review label Jun 26, 2024
@melvin-bot melvin-bot bot added the Overdue label Jun 26, 2024
@mallenexpensify mallenexpensify added Awaiting Payment Auto-added when associated PR is deployed to production and removed Overdue labels Jun 26, 2024
@melvin-bot melvin-bot bot added the Overdue label Jun 26, 2024
@mallenexpensify
Copy link
Contributor

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:

  • [@] The PR that introduced the bug has been identified. Link to the PR:
  • [@] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@] Determine if we should create a regression test for this bug.
  • [@] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@bz] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  • [ ]

@mallenexpensify mallenexpensify added Daily KSv2 and removed Weekly KSv2 labels Jun 26, 2024
@melvin-bot melvin-bot bot removed the Overdue label Jun 26, 2024
Copy link

melvin-bot bot commented Jun 27, 2024

@johncschuster @NikkiWines @allroundexperts @c3024 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!

@allroundexperts
Copy link
Contributor

On to the checklist today.

@allroundexperts
Copy link
Contributor

Checklist

  1. Add One Transaction Report View #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
Copy link
Contributor

@JmillsExpensify
Copy link

$250 approved for @allroundexperts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
No open projects
Archived in project
Development

No branches or pull requests

7 participants