Skip to content

Give TotalCell a dedicated inline amount input over a signed value - #104570

Merged
mountiny merged 12 commits into
Expensify:mainfrom
software-mansion-labs:jmgraa/total-cell-amount-input
Oct 30, 2026
Merged

mountiny merged 12 commits into
Expensify:mainfrom
software-mansion-labs:jmgraa/total-cell-amount-input

Conversation

@jmgraa

@jmgraa jmgraa commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Previously, TotalCell relied on MoneyRequestAmountInput for inline amount editing in transaction table rows (a legacy carryover from NumberWithSymbolForm-based amount entry). Because MoneyRequestAmountInput is designed as a broad form adapter, using it inside a compact table cell required heavy styling overrides to suppress its outer wrappers, borders, and scroll containers. Furthermore, editing negative amounts (such as Split Bills or credits) risked sign desynchronization during mid-edit re-renders.

TotalCell is the only inline context in the app requiring a detached minus sign placed outside the currency symbol (-$12.34). Because standard form inputs like NumericField encapsulate the entire signed value inside a single text field, TotalCell cannot use NumericField. Instead, it shares the underlying detached sign controller (useDetachedSignEditingController) and selection mechanics powering NumericInput, tailored specifically for an inline table cell.

This PR replaces MoneyRequestAmountInput in TotalCell with a dedicated, lightweight EditableTotalAmountInput:

  • Dedicated Inline Component (EditableTotalAmountInput):
    • Uses useDetachedSignEditingController to render the minus sign, the currency symbol, and the right-aligned amount input as separate visual elements in the row (-$12.34).
    • Locks the sign mode on mount alongside the seed value (hasFixedNegativeSign vs. canFlipSign), preventing mid-edit updates from stripping, doubling, or flipping the negative sign on Split Bills.
    • Improves accessibility: marks decorative sign and currency text as aria-hidden and prepends unicode minus \u2212 to accessibilityLabel when negative so screen readers announce "minus".
    • Adds compact NumericFlipButton support for touchscreen devices where soft decimal keyboards lack a minus key.
  • In-Cell Navigation and Caret Placement:
    • Integrates useNumericPressSelection to ensure accurate caret placement without losing focus when clicking the empty cell area to the left of the input.
    • Keeps currency symbol and minus sign pinned during long amount entries, allowing the input to scroll internally without pushing symbols out of view.
  • Simplified TotalCell Logic:
    • Removes local isNegative state and delegates signed value normalization directly to originalValue and getNormalizedValue.
    • Cleans up obsolete container padding hacks, scroll view styles, and unused props.
  • Sign Behavior and Full-Screen Parity:
    • Clears the minus sign when the entire magnitude of a flippable negative amount is selected and overwritten (e.g. selecting 10.00 in -$10.00 and typing 5), treating the edit as a fresh positive entry (+$5.00) to match NumericInput and the full-screen amount editor.
    • Keeps the negative sign permanently locked on non-flippable amounts (such as Split Bills), ensuring hasFixedNegativeSign preserves the sign even when the entire magnitude is replaced.
  • Test Coverage:
    • Adds unit tests for useDetachedSignEditingController covering standalone table cell usage, sign locking, and full-magnitude replacement.
    • Updates TotalCellTest.tsx to verify inline editing flows, minus sign preservation for Split Bills, whole-range selection replacements, long amount boundaries, and discarding draft edits on Escape.
    • Adds tests for compact NumericFlipButton and touchscreen vs. non-touchscreen rendering (TotalCellWithoutTouchScreenTest.tsx).

Fixed Issues

$ #98171
PROPOSAL: #97970

Tests

Platform & Layout Scope:

  • Wide layout (Desktop Web, wide browser window): Inline editing is active. On cursor-based devices, hover over the cell to reveal the edit pencil. On touch-only wide screens (e.g. iPad), hover is unavailable, so inline editing is initiated via keyboard navigation: press Tab to focus the cell's edit button, then press Enter.
  • Narrow layout (Mobile Web, iOS, Android): Transaction rows are read-only; pressing the row opens transaction details in RHP.

A. Wide Layout

  1. Open Search and select the Expenses query (or any filter showing transactions).
  2. Hover over the Amount cell of an editable transaction and click the edit pencil (or press Tab to focus the edit button and hit Enter).
  3. Verify that the input focuses, the currency symbol is displayed, and the cursor is placed correctly.
  4. Click the empty space to the left of the right-aligned amount:
    • Verify that the input remains focused and does not save or blur.
  5. Type a new amount (e.g. change 10.00 to 25.50) and click outside the cell (or press Enter):
    • Verify the updated total saves and formats correctly.
  6. Open inline editing on a negative transaction:
    • For a Split Bill (non-flippable sign):
      • Verify the leading minus sign is displayed outside the currency symbol (e.g. -$12.34).
      • Select the entire magnitude and type a new number (e.g. replace 12.34 with 50.00).
      • Verify the minus sign remains intact and cannot be flipped, doubled, or stripped (saves -$50.00).
    • For an editable negative expense / credit (flippable sign):
      • Select the entire magnitude and type a new number (e.g. replace 10.00 in -$10.00 with 5).
      • Verify that replacing the entire magnitude clears the minus sign, saving a positive amount (+$5.00), matching full-screen amount editor parity.
  7. Type a long amount (e.g. 9999999999.99):
    • Verify that the amount scrolls within the input while the currency symbol (and minus sign if negative) remains visible on the left.
  8. On a touchscreen device or using browser touch emulation (where sign flip is allowed):
    • Verify that a compact flip (+/-) button is displayed next to the input.
    • Tap the button and verify it toggles the negative sign.
  9. Click to edit any amount, change some digits, and press Escape:
    • Verify editing cancels and the original amount is restored without saving.

B. Narrow Layout

  1. Open Search or an Expense Report.
  2. Verify that positive and negative amounts display correctly (with proper currency formatting and -$ prefix for negative amounts).
  3. Tap the transaction row and verify that it opens the transaction detail page in RHP.
  • Verify that no errors appear in the JS console

Offline tests

  1. Disconnect network connectivity.
  2. Edit an amount in a transaction cell following the wide layout steps above.
  3. Verify that the edit applies optimistically with a pending indicator.
  4. Re-enable network connectivity and verify that the updated amount syncs successfully.

QA Steps

Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native android_h android_v
Android: mWeb Chrome chrome_mweb
iOS: Native ios_h ios_v
iOS: mWeb Safari (wide layout)
Before
before_wide.mov
After
after_wide.mov
MacOS: Chrome / Safari
web.mov

@jmgraa

jmgraa commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T19:12:53.962738Z 8a896fe Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: 18f415b433

ℹ️ 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".

@JakubKorytko JakubKorytko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I tested it on the web and couldn't find any problems. Some minor comments, but otherwise LGTM

@JakubKorytko

Copy link
Copy Markdown
Member

@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

Review

The refactor is clean, and the Enter, Escape and blur paths are safe. hasEndedRef in useInlineEditState stops blurAndSubmit from saving twice. I found two behavior changes in negative amount editing that you should resolve before merge.

1. Touch wide layouts can no longer flip the sign (agrees with the Codex P2).
The old input showed a Flip button when allowFlippingAmount && canUseTouchScreen (NumberWithSymbolForm.tsx:806-820). EditableTotalAmountInput.tsx:102-150 has no flip control. iPad decimal pads have no minus key, so an iPad user can't make an amount negative in the cell. controller.toggleSign already exists, so a small flip button gated on canFlipSign && canUseTouchScreen would restore this.

2. Replacing the whole number of a negative credit now saves a positive amount.
When the sign can be flipped (for example, a negative unreported expense), selecting all of 12.34 in -$12.34 and typing 50 saves 50.00. signedMagnitude.ts:26-28 drops the sign on a full replacement. The old TotalCell kept isNegative as separate state, so it stayed -50.00. The new test (TotalCellTest.tsx:343) shows this is intended. But test step A.6 says a credit's sign "cannot be flipped, doubled, or stripped", which only holds for Split Bills. A user who selects all and retypes a credit could silently turn it into an expense. Please either keep the sign on full replacement in this cell, or update step A.6 and confirm the change with the issue owner.

Your existing inline comments still apply: the per-row formatToParts cost, the screen reader missing the minus, and the duplicate backspace test. Only the checklist and independent-approval checks are failing.


view run

@jmgraa
jmgraa force-pushed the jmgraa/total-cell-amount-input branch from aaa303d to e49fb2d Compare October 22, 2026 12:00
@jmgraa
jmgraa force-pushed the jmgraa/total-cell-amount-input branch from e49fb2d to 7c25f28 Compare October 22, 2026 15:45
@jmgraa

jmgraa commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

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

Copy link
Copy Markdown

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: 251b1ceb1e

ℹ️ 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 thread tests/ui/NumericButtonTest.tsx Resolved
@jmgraa

jmgraa commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 8a896fe3dd

ℹ️ 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".

@jmgraa
jmgraa marked this pull request as ready for review October 22, 2026 18:56
@jmgraa
jmgraa requested review from a team as code owners October 22, 2026 18:56
@melvin-bot
melvin-bot Bot requested review from bernhardoj and removed request for a team October 22, 2026 18:56
@melvin-bot

melvin-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

@bernhardoj 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]

@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and removed request for a team October 22, 2026 18:56

@JmillsExpensify JmillsExpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@bernhardoj

bernhardoj commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
w.mp4
a.mp4

@bernhardoj bernhardoj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Works fine!

w.mp4

@melvin-bot
melvin-bot Bot requested a review from mountiny October 27, 2026 03:13
@grgia
grgia self-requested a review October 29, 2026 13:57

@grgia grgia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One blocker from running the tests on this branch merged into current main, plus one question on the sign behavior. Details inline.

Comment thread tests/ui/TotalCellTest.tsx Resolved
@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/components/EditableCell/useInlineEditState.ts 96.29% <100.00%> (ø)
...rc/components/NumericButtons/NumericFlipButton.tsx 100.00% <100.00%> (ø)
...ponents/TransactionItemRow/DataCells/TotalCell.tsx 96.00% <100.00%> (+2.45%) ⬆️
...tionItemRow/DataCells/EditableTotalAmountInput.tsx 92.75% <92.75%> (ø)
... and 16 files with indirect coverage changes

@mountiny mountiny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM thank you

@mountiny
mountiny merged commit 9bc26f2 into Expensify:main Oct 30, 2026
38 of 39 checks passed
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

Copy link
Copy Markdown
Contributor

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.5.27-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed. This PR swaps the input behind inline amount editing, and the existing steps ("hover over amount and click the pencil icon") in Edit Expenses and Getting Started with the Spend Page are still accurate.


view run

@jmgraa
jmgraa deleted the jmgraa/total-cell-amount-input branch November 2, 2026 08:18
@OSBotify

OSBotify commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/blimpich in version: 9.5.27-2 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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.

8 participants