Skip to content

Reapply PR #56092: Add PlusMinus icon and allow negative values in MoneyRequestAmountInput#65545

Closed
Copilot wants to merge 1 commit intomainfrom
copilot/fix-d8b8fbaf-e265-4852-a757-4d1787339286
Closed

Reapply PR #56092: Add PlusMinus icon and allow negative values in MoneyRequestAmountInput#65545
Copilot wants to merge 1 commit intomainfrom
copilot/fix-d8b8fbaf-e265-4852-a757-4d1787339286

Conversation

Copy link

Copilot AI commented Jul 7, 2025

Summary

This PR reapplies all changes from PR #56092 "Add PlusMinus icon and allow negative values in MoneyRequestAmountInput" that were reverted by PR #64919. The implementation restores the complete negative value functionality for expense reporting, matching the state after merge commit 146dd00.

Changes Made

Core Functionality

  • Added PlusMinus Icon: Created assets/images/plus-minus.svg and integrated it into the Expensicons system
  • Negative Amount Support: Comprehensive UI and backend support for negative expense amounts
  • Flip Button: Mobile-friendly toggle button for switching between positive and negative amounts
  • Workspace Constraint: Negative amounts are only allowed for workspace expenses, not personal or split bills

Files Modified (26 total)

UI Components

  • src/components/MoneyRequestAmountInput.tsx - Added negative value props and logic
  • src/components/TextInputWithCurrencySymbol/BaseTextInputWithCurrencySymbol.tsx - Added negative symbol display
  • src/components/TextInputWithCurrencySymbol/types.ts - Added isNegative prop type
  • src/pages/iou/MoneyRequestAmountForm.tsx - Added flip button and negative state management
  • src/pages/iou/request/MoneyRequestParticipantsSelector.tsx - Added workspace-only filtering for negative amounts
  • src/pages/iou/request/step/IOURequestStepAmount.tsx - Added negative amount support
  • src/pages/iou/request/step/IOURequestStepConfirmation.tsx - Removed Math.abs() to preserve negative values
  • src/pages/iou/request/step/IOURequestStepParticipants.tsx - Added workspace constraint logic

Backend Logic

  • src/libs/TransactionUtils/index.ts - Updated getAmount() with allowNegative and disableOppositeConversion parameters
  • src/libs/ReportUtils.ts - Added shouldEnableNegative() function and updated transaction processing
  • src/libs/actions/IOU.ts - Updated money request handlers to support negative amounts
  • src/libs/ModifiedExpenseMessage.ts - Fixed amount comparison to handle negative values

Internationalization

  • Added "flip" translation to all 10 supported languages:
    • src/languages/en.ts - "Flip"
    • src/languages/de.ts - "Umkehren"
    • src/languages/es.ts - "Cambiar"
    • src/languages/fr.ts - "Inverser"
    • src/languages/it.ts - "Inverti"
    • src/languages/ja.ts - "反転"
    • src/languages/nl.ts - "Omdraaien"
    • src/languages/pl.ts - "Odwróć"
    • src/languages/pt-BR.ts - "Inverter"
    • src/languages/zh-hans.ts - "翻转"

Supporting Files

  • src/components/Icon/Expensicons.ts - Added PlusMinus icon export
  • src/styles/utils/spacing.ts - Added minWidth18 style for flip button
  • src/components/ReportActionItem/MoneyRequestView.tsx - Updated to use negative-aware transaction details

Technical Implementation

New Props and Functions

  • allowFlippingAmount: boolean - Controls visibility of flip button
  • isNegative: boolean - Tracks negative state
  • toggleNegative() - Toggles between positive/negative
  • clearNegative() - Resets to positive
  • shouldEnableNegative(report, policy, iouType) - Determines if negative amounts are allowed

Amount Processing

  • Updated getAmount() in TransactionUtils to preserve negative values when allowNegative=true
  • Modified expense report calculations to maintain sign for negative expenses
  • Added disableOppositeConversion parameter to bypass automatic sign flipping

UI Behavior

  • Mobile: Shows flip button for workspace expenses
  • Desktop: Allows manual - input for workspace expenses
  • Split Bills: Negative amounts disabled
  • Personal Expenses: Negative amounts disabled
  • Workspace Expenses: Full negative amount support

Testing

✅ All automated tests pass
✅ Icon integration verified
✅ Translation coverage confirmed
✅ Component prop validation successful
✅ Backend logic validation complete

Manual Testing Scenarios

Based on the original PR test plan:

Mobile Testing

  1. Negative expense creation - Verify flip button appears and functions
  2. Workspace requirement - Confirm negative amounts only work with workspace
  3. Amount preservation - Verify negative amounts are saved and displayed correctly
  4. Split bill restriction - Confirm flip button is disabled for split bills

Desktop Testing

  1. Manual negative input - Verify - key input works for workspace expenses
  2. Input validation - Confirm negative input is blocked for personal/split expenses
  3. Amount updates - Verify negative amounts are preserved through edits

Related Issues

Risk Assessment

Low Risk - This is a direct restoration of previously merged and tested functionality. All changes are isolated to expense reporting flows and maintain backward compatibility.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@nkuoch nkuoch closed this Jul 7, 2025
Copilot AI changed the title [WIP] Reapply changes from reverted PR #56092: Allow negative values in MoneyRequestAmountInput Reapply PR #56092: Add PlusMinus icon and allow negative values in MoneyRequestAmountInput Jul 7, 2025
Copilot AI requested a review from nkuoch July 7, 2025 09:56
Copilot finished work on behalf of nkuoch July 7, 2025 09:56
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.

2 participants