Skip to content

Split - Error splitting expense after submitting a distance expense #43798

Closed

Description

@lanitochka17

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.84-0
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

Issue found when executing PR #42069

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to FAB > Submit expense > Distance
  3. Submit distance expense to a workspace chat
  4. Go to transaction thread
  5. Go to FAB > Split expense > Manual
  6. Split manual expense with a few users

Expected Result:

A new group chat will be created without issue

Actual Result:

There is error splitting expense after submitting a distance expense

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

Bug6514115_1718473333242.distance-and-split_VXUmZEpF.mp4

View all open jobs on GitHub

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 15, 2024
  2. melvin-bot commented on Jun 15, 2024

    @melvin-bot

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

  3. lanitochka17 commented on Jun 15, 2024

    @lanitochka17
    Author

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

  4. lanitochka17 commented on Jun 15, 2024

    @lanitochka17
    Author

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

  5. truph01 commented on Jun 17, 2024

    @truph01
    Contributor

    Proposal

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

    There is error splitting expense after submitting a distance expense

    What is the root cause of that problem?

    We call OpenReport API in withWritableReportOrNotFound if the reportID doesn't exist in report data. So in the create flow, OpenReport API is called every time we open a step in this flow.

    ReportActions.openReport(route.params.reportID);

    When we navigate to the waypoint page, we pass the reportID param as report?.reportID which will be undefined when we create a new request via FAB, and then OpenReport API is called with reportID is undefined which will store the report data with key report_undefined in Onyx.

    ROUTES.MONEY_REQUEST_STEP_WAYPOINT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, report?.reportID, index.toString(), Navigation.getActiveRouteWithoutParams()),

    After that, if we create a split expense via FAB, the problem appears here, existingChatReportID is undefined which leads existingSplitChatReport is not empty because in Onyx we have report data with key report_undefined as mentioned above and then we don't create a new optimistic report which makes the SplitBillAndOpenReport fails.

    let existingSplitChatReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${existingChatReportID}`];

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

    1. We should only call the OpenReport API in the edit flow to prevent none exist report can be stored in Onyx in the create flow
    !!report?.reportID || !route.params.reportID || !isEditing
    

    if (!!report?.reportID || !route.params.reportID) {
    return;
    }
    ReportActions.openReport(route.params.reportID);
    // eslint-disable-next-line react-hooks/exhaustive-deps
    }, []);

    1. We should fallback the reportID param in route here so the reportID of waypoint page will not be undefined when we create a distance request
    ROUTES.MONEY_REQUEST_STEP_WAYPOINT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, report?.reportID ?? reportID, index.toString(), Navigation.getActiveRouteWithoutParams()),
    

    ROUTES.MONEY_REQUEST_STEP_WAYPOINT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, report?.reportID, index.toString(), Navigation.getActiveRouteWithoutParams()),

    1. To prevent this bug happening in the feature, we should check reportID of existingSplitChatReport is empty or not instead of checking existingSplitChatReport
    !existingSplitChatReport?.reportID
    

    if (!existingSplitChatReport && shouldGetOrCreateOneOneDM) {

    existingSplitChatReport?.reportID
    

    if (existingSplitChatReport) {

    What alternative solutions did you explore? (Optional)

  6. tsa321 commented on Jun 17, 2024

    @tsa321
    Contributor

    maybe related to #40579

  7. truph01 commented on Jun 18, 2024

    @truph01
    Contributor

    It's not related to #40579. The RCA is different.

  8. zanyrenney commented on Jun 18, 2024

    @zanyrenney
    Contributor

    https://expensify.slack.com/archives/GP2FVSJ7Q/p1718649701046849?thread_ts=1718648773.503349&cid=GP2FVSJ7Q VIP split is on pause, so going to close this for now as it is not a priority right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions