Skip to content

Revert "Allow edit input for SplitListItem when there is negative value"#81717

Closed
mollfpr wants to merge 1 commit intomainfrom
revert-74189-fix-63311
Closed

Revert "Allow edit input for SplitListItem when there is negative value"#81717
mollfpr wants to merge 1 commit intomainfrom
revert-74189-fix-63311

Conversation

@mollfpr
Copy link
Contributor

@mollfpr mollfpr commented Feb 6, 2026

Reverts #74189

@mollfpr mollfpr requested review from a team as code owners February 6, 2026 16:58
@melvin-bot melvin-bot bot requested a review from heyjennahay February 6, 2026 16:59
@melvin-bot
Copy link

melvin-bot bot commented Feb 6, 2026

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

@melvin-bot melvin-bot bot requested review from nkuoch and removed request for a team February 6, 2026 16:59
@melvin-bot
Copy link

melvin-bot bot commented Feb 6, 2026

@nkuoch Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@mollfpr mollfpr closed this Feb 6, 2026
@mollfpr
Copy link
Contributor Author

mollfpr commented Feb 6, 2026

Sorry for the noice @nkuoch @heyjennahay 🙏

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7bfd5582b2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 109 to +113
function calculateSplitAmountFromPercentage(totalInCents: number, percentage: number): number {
// Calculate directly without clamping to support negative percentages
// This naturally handles all sign combinations:
// - Positive total × Positive % = Positive split (normal expense share)
// - Positive total × Negative % = Negative split (person owes money back)
// - Negative total × Positive % = Negative split (person gets refund share)
// - Negative total × Negative % = Positive split (person owes money on a refund)
const amount = Math.round((totalInCents * percentage) / 100);
const totalAbs = Math.abs(totalInCents);
// Clamp percentage to [0, 100] without rounding to preserve decimal precision
const clamped = Math.min(100, Math.max(0, percentage));
const amount = Math.round((totalAbs * clamped) / 100);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not clamp split percentages while edits allow >100

The split-by-percentage input still enables allowExceedingHundred (see SplitPercentageInput), but calculateSplitAmountFromPercentage now clamps percentage to [0,100]. When a user types 110–150% as a temporary edit (the existing UX allows this during multi-split adjustments), the amount is computed as 100%, so the amount no longer reflects the user’s input and the value snaps back when the draft clears. This makes it impossible to use the temporary >100% edits that the UI still accepts.

Useful? React with 👍 / 👎.

Comment on lines 382 to 385
prefixCharacter={symbol}
prefixStyle={styles.colorMuted}
keyboardType={props.keyboardType ?? CONST.KEYBOARD_TYPE.DECIMAL_PAD}
keyboardType={CONST.KEYBOARD_TYPE.DECIMAL_PAD}
// On android autoCapitalize="words" is necessary when keyboardType="decimal-pad" or inputMode="decimal" to prevent input lag.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep keyboardType override for negative split edits

Hardcoding keyboardType to DECIMAL_PAD removes the ability for callers (e.g., split amount inputs) to request a keyboard with a minus key. On iOS, decimal-pad doesn’t include “-”, so if a split amount is negative (refunds/adjustments) and the user clears or replaces the text, they can’t re-enter the negative sign. Previously SplitAmountInput passed a numbers-and-punctuation keyboard to handle this case.

Useful? React with 👍 / 👎.

@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/components/AmountTextInput.tsx 100.00% <ø> (ø)
src/components/MoneyRequestAmountInput.tsx 1.92% <ø> (ø)
src/components/NumberWithSymbolForm.tsx 2.80% <ø> (+0.03%) ⬆️
...onList/ListItem/SplitListItem/SplitAmountInput.tsx 0.00% <ø> (ø)
...st/ListItem/SplitListItem/SplitPercentageInput.tsx 0.00% <ø> (ø)
...nput/BaseTextInput/implementation/index.native.tsx 77.61% <100.00%> (-0.11%) ⬇️
...s/TextInput/BaseTextInput/implementation/index.tsx 0.00% <ø> (ø)
src/libs/MoneyRequestUtils.ts 52.63% <100.00%> (-2.14%) ⬇️
...omponents/SelectionList/ListItem/SplitListItem.tsx 0.00% <0.00%> (ø)
src/libs/IOUUtils.ts 77.38% <91.66%> (+6.28%) ⬆️
... and 3 more
... and 95 files with indirect coverage changes

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant