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

[HOLD for payment 2024-08-13] [HOLD for payment 2024-08-07] [$250] Split - Split amount shows 0.00 in LHN when splitting an expense with no chat history #45855

Closed
1 of 6 tasks
lanitochka17 opened this issue Jul 20, 2024 · 31 comments
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 Jul 20, 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: 9.0.10-2
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. Sign in to staging (Let's call this user A)
  3. Click on FAB
  4. Click on split expense
  5. Enter an amount and click next
  6. Enter a user you have never chatted with before (Let's call this user user B)
  7. Click on next and finish the flow
  8. Sign in as user B
  9. Before opening the chat with user A observe the chat preview in LHN
    (Important : Make sure that you haven't opened the chat with user A)

Expected Result:

The split expense preview in LHN shows the correct split amount

Actual Result:

The split expense amount in the LHN message preview shows 0.00 (Message preview is "User B owes 0.00)

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

Bug6548229_1721493192166.2024-07-20_19_08_12.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01756b0cd389a7093c
  • Upwork Job ID: 1815485176933143349
  • Last Price Increase: 2024-07-22
  • Automatic offers:
    • brunovjk | Reviewer | 103254818
    • tsa321 | Contributor | 103254819
Issue OwnerCurrent Issue Owner: @Christinadobrzyn
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 20, 2024
Copy link

melvin-bot bot commented Jul 20, 2024

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

@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

@lanitochka17
Copy link
Author

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

@tsa321
Copy link
Contributor

tsa321 commented Jul 22, 2024

Proposal

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

Split - Split amount shows owes 0.00 in LHN when splitting an expense with no chat history and after all expense paid.

What is the root cause of that problem?

Here

}, [
fullReport,
lastReportActionTransaction,
reportActions,
personalDetails,
preferredLocale,
policy,
parentReportAction,

The OptionRowLHNData / OptionItem depends only on the reportActions which is itemReportActions (which is the reportActions of report of the option item set by OptionRowLHNData) and the parentReportActions.
When user receive split bills message:

const iouReport = getReportOrDraftReport(ReportActionUtils.getIOUReportIDFromReportActionPreview(lastReportAction));
const lastIOUMoneyReportAction = allSortedReportActions[iouReport?.reportID ?? '-1']?.find(
(reportAction, key): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.IOU> =>
ReportActionUtils.shouldReportActionBeVisible(reportAction, key) &&
reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE &&
ReportActionUtils.isMoneyRequestAction(reportAction),
);
const reportPreviewMessage = ReportUtils.getReportPreviewMessage(
!isEmptyObject(iouReport) ? iouReport : null,
lastIOUMoneyReportAction,

the getReportPreviewMessage won't get the correct message, because lastIOUMoneyReportAction is undefined. This is because onyxUpdates from pusher isn't completed yet. When the onyxUpdates completed the OptionItem won't re-render because it doesn't depend on the reportActions of the iouReport. So it will stay 0.00, until the user receive new messages or user navigate to other report, which will re-render the LHNData.

In the code at:

}, [
fullReport,
lastReportActionTransaction,
reportActions,
personalDetails,
preferredLocale,
policy,
parentReportAction,
)

the OptionRowLHNData or OptionItem relies on reportActions which is itemReportActions (which is the reportActions of the report associated with the option item set by OptionRowLHNData-- so it is not allReportActions), and parentReportActions.

When a user receives a split bill message, as detailed

const iouReport = getReportOrDraftReport(ReportActionUtils.getIOUReportIDFromReportActionPreview(lastReportAction));
const lastIOUMoneyReportAction = allSortedReportActions[iouReport?.reportID ?? '-1']?.find(
(reportAction, key): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.IOU> =>
ReportActionUtils.shouldReportActionBeVisible(reportAction, key) &&
reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE &&
ReportActionUtils.isMoneyRequestAction(reportAction),
);
const reportPreviewMessage = ReportUtils.getReportPreviewMessage(
!isEmptyObject(iouReport) ? iouReport : null,
lastIOUMoneyReportAction,

the getReportPreviewMessage function does not retrieve the correct message because lastIOUMoneyReportAction is undefined. This occurs because the onyxUpdates from Pusher have not completed yet. Once the onyxUpdates are complete, the OptionItem does not re-render because it does not depend on the reportActions of the iouReport. As a result, it will continue to display 0.00 until the user receives new messages or navigates to another report, triggering a re-render of the LHNData.

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

We should add a dependency for the OptionItem to rely on the reportActions of the IOUReport or reports that are associated with the last message of the item's report. To achieve this, we could create utility functions in OptionsListUtils to retrieve the relevant report IDs (in this issue it is the iouReport.reportID).

The code could be:

function getIOUReportIDOfLastAction(report) {
    const lastAction = visibleReportActionItems[report.reportID];
    if (ReportActionUtils.isReportPreviewAction(lastAction)) {
        return getReportOrDraftReport(ReportActionUtils.getIOUReportIDFromReportActionPreview(lastAction))?.reportID;
    }
}

We could name it getIOUReportIDOfLastAction. If we need more generalized report IDs, we could name it getReportIDsRelatedToLastAction.

Then in LHNOptionList, within renderItem, we would then add:

const iouReportIDOfLastAction = OptionsListUtils.getIOUReportIDOfLastAction(itemFullReport);
const itemIouReportReportActions = !!iouReportIDOfLastAction ? reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportIDOfLastAction}`] : undefined;

This addition ensures that the OptionItem appropriately depends on relatedReportIDsReportActions or in this issue: iouReportReportActions.

Next, add itemIouReportReportActions to the properties of OptionRowLHNData. Then, within the useMemo of OptionItem, include IOUReportReportActions as a dependency.

Result:
macos-web-d.mp4
Result

Alternative solutions

We could add dependency of the OptionItem to depend on all report actions, but this is very inefficient

@Christinadobrzyn Christinadobrzyn added the Needs Reproduction Reproducible steps needed label Jul 22, 2024
@Christinadobrzyn
Copy link
Contributor

Christinadobrzyn commented Jul 22, 2024

I'm not able to reproduce this, I see the correct amount in the LHN of the split user.

image

I'll ask QA for some more details on how to reproduce this. #45855

@MelvinBot
Copy link

This has been labelled "Needs Reproduction". Follow the steps here: https://stackoverflowteams.com/c/expensify/questions/16989

@kavimuru
Copy link

  1. Sign in as User A
  2. Sign in as user B in another browser or in cognito
  3. As user A split expense with User B (Make sure that the users have no previous chat history)
  4. After the split expense is created observe the LHN in the tab where you are logged in as user B (Before opening the chat)
2024-07-22.22.53.33.mp4

@Christinadobrzyn
Copy link
Contributor

Christinadobrzyn commented Jul 22, 2024

I'm not getting the same results - I see the actual amount that was split in the LHN but it sounds like QA has been able to reproduce this so we'll keep moving it forward.

Starting with this as an external job

@Christinadobrzyn Christinadobrzyn added External Added to denote the issue can be worked on by a contributor and removed Needs Reproduction Reproducible steps needed labels Jul 22, 2024
@melvin-bot melvin-bot bot changed the title Split - Split amount shows 0.00 in LHN when splitting an expense with no chat history [$250] Split - Split amount shows 0.00 in LHN when splitting an expense with no chat history Jul 22, 2024
Copy link

melvin-bot bot commented Jul 22, 2024

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

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

melvin-bot bot commented Jul 22, 2024

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

@brunovjk
Copy link
Contributor

I will reproduce and review proposal first thing in the morning.

@tsa321
Copy link
Contributor

tsa321 commented Jul 22, 2024

@Christinadobrzyn another way to reproduce it:

  1. User A opens a chat with user B.
  2. User A pays off all debts owed to user B.
  3. User A opens another chat, for example, Concierge.
  4. User B sends a split IOU request to user A.
  5. Note that in the LHN chat with user B, user A sees "... owes 0.00".

@brunovjk
Copy link
Contributor

I was able to reproduce the issue consistently.
@tsa321 your proposal makes sense to me, but I didn't get to test it 100%. Would you mind to share a test-branch? Thanks.

@tsa321
Copy link
Contributor

tsa321 commented Jul 24, 2024

@brunovjk this is the test branch: https://github.com/tsa321/App/tree/fixLhnDisplaysOwes000

@brunovjk
Copy link
Contributor

Thank you very much for the test branch, look good to me. We can go with @tsa321's proposal.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Jul 24, 2024

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

@neil-marcellini
Copy link
Contributor

We can go with @tsa321's proposal.

I agree, assigning.

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

melvin-bot bot commented Jul 24, 2024

📣 @brunovjk 🎉 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

@tsa321
Copy link
Contributor

tsa321 commented Jul 25, 2024

@brunovjk PR is ready

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jul 31, 2024
@melvin-bot melvin-bot bot changed the title [$250] Split - Split amount shows 0.00 in LHN when splitting an expense with no chat history [HOLD for payment 2024-08-07] [$250] Split - Split amount shows 0.00 in LHN when splitting an expense with no chat history Jul 31, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 31, 2024
Copy link

melvin-bot bot commented Jul 31, 2024

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

Copy link

melvin-bot bot commented Jul 31, 2024

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

If no regressions arise, payment will be issued on 2024-08-07. 🎊

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

Copy link

melvin-bot bot commented Jul 31, 2024

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:

  • [@brunovjk] The PR that introduced the bug has been identified. Link to the PR:
  • [@brunovjk] 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:
  • [@brunovjk] 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:
  • [@brunovjk] Determine if we should create a regression test for this bug.
  • [@brunovjk] 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.
  • [@Christinadobrzyn] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Weekly KSv2 labels Aug 1, 2024
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-08-07] [$250] Split - Split amount shows 0.00 in LHN when splitting an expense with no chat history [HOLD for payment 2024-08-13] [HOLD for payment 2024-08-07] [$250] Split - Split amount shows 0.00 in LHN when splitting an expense with no chat history Aug 6, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Aug 6, 2024
Copy link

melvin-bot bot commented Aug 6, 2024

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

Copy link

melvin-bot bot commented Aug 6, 2024

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

If no regressions arise, payment will be issued on 2024-08-13. 🎊

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

Copy link

melvin-bot bot commented Aug 6, 2024

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:

  • [@brunovjk] The PR that introduced the bug has been identified. Link to the PR:
  • [@brunovjk] 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:
  • [@brunovjk] 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:
  • [@brunovjk] Determine if we should create a regression test for this bug.
  • [@brunovjk] 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.
  • [@Christinadobrzyn] Link the GH issue for creating/updating the regression test once above steps have been agreed upon: https://github.com/Expensify/Expensify/issues/418884

@brunovjk
Copy link
Contributor

brunovjk commented Aug 6, 2024

  • [@brunovjk] The PR that introduced the bug has been identified. Link to the PR: N/A
  • [@brunovjk] 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: N/A
  • [@brunovjk] 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: N/A
  • [@brunovjk] Determine if we should create a regression test for this bug. Yes
  • [@brunovjk] 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.

Regression Test Proposal:

  1. User A opens a chat with user B.
  2. User A pays off all debts owed to user B.
  3. User A opens another chat, for example, Concierge.
  4. User B sends a split IOU request to user A.
  5. Verify that in the LHN chat with user B, user A sees correct split amount.

Do we agree 👍 or 👎

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Aug 7, 2024
@Christinadobrzyn
Copy link
Contributor

Christinadobrzyn commented Aug 8, 2024

Payouts due:

Regression test - https://github.com/Expensify/Expensify/issues/418884

@Christinadobrzyn
Copy link
Contributor

We've got a few more days before payday.

@melvin-bot melvin-bot bot added the Overdue label Aug 12, 2024
@Christinadobrzyn
Copy link
Contributor

tomorrow is day 7 so we'll pay out based on this payment summary - #45855 (comment)

@melvin-bot melvin-bot bot removed the Overdue label Aug 12, 2024
@Christinadobrzyn
Copy link
Contributor

Payment day - paid based on this payment summary

Closing as complete

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
None yet
Development

No branches or pull requests

7 participants