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] Group Chat - Error displayed for Split, Distance expenses created with specific currencies #52310

Open
1 of 8 tasks
m-natarajan opened this issue Nov 11, 2024 · 35 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@m-natarajan
Copy link

m-natarajan commented Nov 11, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.59-3
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @jacobkim9881
Slack conversation (hyperlinked to channel name): ts_external_expensify_open_source

Action Performed:

Prerequisite: Default currency in Korean Won

  1. Create a group chat
  2. Click the + in composer and select split expense
  3. Select Distance and enter address for Start and Stop field
  4. Click Next

Expected Result:

Amount equally split and user able to click split button to submit the expense

Actual Result:

The sum of splits must equal the total amount error message displayed and split button non functional

Workaround:

Unknown

Platforms:

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

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
2024-11-08.7.14.00.mov

Full Screen #36

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021861139216888650784
  • Upwork Job ID: 1861139216888650784
  • Last Price Increase: 2024-12-09
  • Automatic offers:
    • mkzie2 | Contributor | 105275673
Issue OwnerCurrent Issue Owner: @rushatgabhane
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Nov 11, 2024
Copy link

melvin-bot bot commented Nov 11, 2024

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

@jacobkim9881
Copy link
Contributor

I found there is a difference between total amount and split shares:

transaction: 
Object
amount: 519357        /////// not rounded
attendees: [Object] (1)
billable: false
category: ""
comment: {waypoints: Object, customUnit: {customUnitRateID: "_FAKE_P2P_ID_", quantity: 4281.895}, isLoading: false}
created: "2024-11-12"
currency: "KRW"
errorFields: {}
iouRequestType: "distance"
isFromGlobalCreate: false
merchant: "4.28 km @ ₩1213.45 / km"
participants: [{accountID: 18602521, selected: true}] (1)
participantsAutoAssigned: true
pendingFields: {}
reportID: "4715962770440927"
routes: {route0: Object}
shouldShowOriginalAmount: false
splitPayerAccountIDs: [18608989] (1)
splitShares: Object
/////////////// rounded here below
18602521: {amount: 259700, isModified: false}
18608989: {amount: 259700, isModified: false}
Object 견본
transactionID: "1"

const {unit, rate} = mileageRate ?? {};
const distance = TransactionUtils.getDistanceInMeters(transaction, unit);
const currency = mileageRate?.currency ?? policyCurrency;
const amount = DistanceRequestUtils.getDistanceRequestAmount(distance, unit ?? CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES, rate ?? 0);
IOU.setMoneyRequestAmount(transactionID, amount, currency);
const participantAccountIDs: number[] | undefined = participants?.map((participant) => Number(participant.accountID ?? -1));
if (isSplitRequest && amount && currency && !isPolicyExpenseChat) {
IOU.setSplitShares(transaction, amount, currency ?? '', participantAccountIDs ?? []);
}

There is code for decision how the total is same with split shares. I tried to round total amount from 519357 to 519400. For this calculation, round method is needed but needed parameter currency above always be undefined. Why mileageRate?.currency, policyCurrency are undefined? I am tracing the reason.

@mkzie2
Copy link
Contributor

mkzie2 commented Nov 12, 2024

Proposal

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

The sum of splits must equal the total amount error message displayed and split button non functional

What is the root cause of that problem?

The total amount is calculated by calculateAmount function

const splitAmount = IOUUtils.calculateAmount(participantsLength, amount, currency, isPayer);

The total amount of the split bill is rounded before we calculate the split amount

const totalInCurrencySubunit = Math.round((total / 100) * currencyUnit);

then if the rounded total amount is different from the current amount, the error appears here

if (sumOfShares !== iouAmount) {
setFormError('iou.error.invalidSplit');
return;

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

When calculating the split amount, we should remove the Math.round here so that we do not round the total amount but only the split amount.

const totalInCurrencySubunit = (total / 100) * currencyUnit;

const totalInCurrencySubunit = Math.round((total / 100) * currencyUnit);

What alternative solutions did you explore? (Optional)

@OfstadC
Copy link
Contributor

OfstadC commented Nov 12, 2024

Can confirm
image

But this only happens for this currency - I tried two other currencies and did not get the same response. So not sure how high priority this will be. It's likely uncommon to split a mileage expense, and this would only affect a subset of users
image

@mkzie2
Copy link
Contributor

mkzie2 commented Nov 13, 2024

@OfstadC This bug also happens for some other currencies like VND.

@OfstadC
Copy link
Contributor

OfstadC commented Nov 13, 2024

Added to Quality and posted in Slack for prioritization

@tgolen
Copy link
Contributor

tgolen commented Nov 13, 2024

Does this only affect distance expenses, or does it happen to any split?

@mkzie2
Copy link
Contributor

mkzie2 commented Nov 14, 2024

This only affects distance expense, the reason is the rate is odd.

@OfstadC
Copy link
Contributor

OfstadC commented Nov 14, 2024

Will test this a bit more first thing tomorrow morning - had a managed customer issue that threw my day off today 😓

@OfstadC
Copy link
Contributor

OfstadC commented Nov 15, 2024

Can confirm it does not affect regular splits - just distance. But for the life of me I cannot remember how to change the currency on a distance expense in ND 🤦‍♀️ So working on that now 😅

@OfstadC
Copy link
Contributor

OfstadC commented Nov 15, 2024

Figured the currency out - so ignore me lol. Testing them now

@OfstadC
Copy link
Contributor

OfstadC commented Nov 15, 2024

@mkzie2 I couldn't reproduce with VND - Or other currencies with 'decimals' => 0, I tested about 20 currencies all together🤔

@melvin-bot melvin-bot bot added the Overdue label Nov 18, 2024
@OfstadC
Copy link
Contributor

OfstadC commented Nov 18, 2024

@mkzie2 are you still able to reproduce with other currencies? 🤔

@melvin-bot melvin-bot bot removed the Overdue label Nov 18, 2024
@mkzie2
Copy link
Contributor

mkzie2 commented Nov 19, 2024

@OfstadC Yes I can, an example for VND.

Screen.Recording.2024-11-19.at.17.27.52.mov

@OfstadC
Copy link
Contributor

OfstadC commented Nov 20, 2024

Thanks @mkzie2 - i'm going to have to try this again 🤔

@OfstadC
Copy link
Contributor

OfstadC commented Nov 22, 2024

I'm still having issues 🤔 .

@melvin-bot melvin-bot bot added the Overdue label Nov 25, 2024
Copy link

melvin-bot bot commented Nov 25, 2024

@OfstadC this issue was created 2 weeks ago. Are we close to a solution? Let's make sure we're treating this as a top priority. Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@OfstadC
Copy link
Contributor

OfstadC commented Nov 25, 2024

Ah - so this does not happen in a workspace chat - only a group DM

image image

@melvin-bot melvin-bot bot removed the Overdue label Nov 25, 2024
@OfstadC
Copy link
Contributor

OfstadC commented Nov 25, 2024

Tested another handful in the group chat - not workspace chat 😅 :

Error occurs on these currencies:
ALL, AFN, BIF, CLP

Does not occur for:
AMD, ANG, CAD, CUP

So I believe the theory that it occurs for Currencies where 'decimals' => 0, is listed - is accurate.

@OfstadC OfstadC changed the title Error message displayed for split distance created in Korean Won currency Group Chat - Error displayed for Split, Distance expenses created with specific currencies Nov 25, 2024
@OfstadC OfstadC added the External Added to denote the issue can be worked on by a contributor label Nov 25, 2024
@melvin-bot melvin-bot bot changed the title Group Chat - Error displayed for Split, Distance expenses created with specific currencies [$250] Group Chat - Error displayed for Split, Distance expenses created with specific currencies Nov 25, 2024
Copy link

melvin-bot bot commented Nov 25, 2024

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

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

melvin-bot bot commented Nov 25, 2024

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

@rushatgabhane
Copy link
Member

waiting for proposals

@mkzie2
Copy link
Contributor

mkzie2 commented Nov 26, 2024

@rushatgabhane My proposal is here.

Copy link

melvin-bot bot commented Dec 2, 2024

@OfstadC, @rushatgabhane Huh... This is 4 days overdue. Who can take care of this?

@melvin-bot melvin-bot bot added the Overdue label Dec 2, 2024
Copy link

melvin-bot bot commented Dec 2, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@muttmuure muttmuure moved this to MEDIUM in [#whatsnext] #quality Dec 2, 2024
@rushatgabhane
Copy link
Member

The total amount of the split bill is rounded before we calculate the split amount
then if the rounded total amount is different from the current amount, the error appears here
#52310 (comment)

@mkzie2 could you please explain the root cause with some example values?
The root cause you've mentioned is - we round total amount and compare it against non rounded amount and hence the error?

But then another fix would be to round the amount where we're comparing it too, right?
It'll help if you demonstrate a few numbers with example, thank you! 🙇

@melvin-bot melvin-bot bot removed the Overdue label Dec 2, 2024
Copy link

melvin-bot bot commented Dec 6, 2024

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

@melvin-bot melvin-bot bot added the Overdue label Dec 6, 2024
@mkzie2
Copy link
Contributor

mkzie2 commented Dec 6, 2024

@rushatgabhane For example, the current amount 16410076,54

Screenshot 2024-12-06 at 16 31 42

totalInCurrencySubunit will be rounded to 16410077 here.

const totalInCurrencySubunit = Math.round((total / 100) * currencyUnit);

Then we calculate the split amount based on this rounded amount 16410077.

So the sumOfShares is 16410077 which is different from 16410076,54

if (sumOfShares !== iouAmount) {
setFormError('iou.error.invalidSplit');
return;

Copy link

melvin-bot bot commented Dec 9, 2024

@OfstadC @rushatgabhane 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!

Copy link

melvin-bot bot commented Dec 9, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

Copy link

melvin-bot bot commented Dec 10, 2024

@OfstadC, @rushatgabhane 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

@rushatgabhane
Copy link
Member

@mkzie2's proposal LGTM 🎀👀🎀

#52310 (comment)

Copy link

melvin-bot bot commented Dec 10, 2024

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

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

melvin-bot bot commented Dec 10, 2024

📣 @mkzie2 🎉 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 📖

@mkzie2
Copy link
Contributor

mkzie2 commented Dec 12, 2024

@rushatgabhane The PR is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
Development

No branches or pull requests

7 participants