Commit 9432aa0
authored
fix(MUSD-701): use Money Account balance in Add money sheet (MetaMask#29734)
## **Description**
The "Move mUSD" row in the Add money sheet was showing a balance that
did not match the Money Account balance displayed at the top of the
screen. The two figures were sourced from different places, which
surfaced as an obvious mismatch whenever the selected EVM account was
not the same as the Money Account.
Root cause: the sheet was reading from
`useMusdBalance().fiatBalanceAggregatedFormatted`, which aggregates mUSD
across the currently selected EVM account. The screen header, by
contrast, uses `useMoneyAccountBalance`, which is the canonical Money
Account balance.
Fix: switch the sheet to consume
`useMoneyAccountBalance().totalFiatFormatted` so the "Move mUSD" amount
and the header always agree. Tests were updated to mock the new hook and
assert the same fallback behaviour (no-amount copy when the balance is
unavailable, locale fiat prefix preserved).
Credit to Matthew Grainger for diagnosing the source-of-truth mismatch
on the Jira ticket.
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes: MUSD-701
## **Manual testing steps**
```gherkin
Feature: Add money sheet balance consistency
Scenario: user opens the Add money sheet with a funded Money Account
Given the user has a non-zero Money Account balance
And the selected EVM account is not the Money Account
When the user opens the Add money sheet
Then the "Move mUSD" row shows the same fiat amount as the Money Account header
Scenario: user opens the Add money sheet with no mUSD
Given the user's Money Account balance is unavailable or zero
When the user opens the Add money sheet
Then the "Move mUSD" row shows the no-amount copy
```
## **Screenshots/Recordings**
### **Before**
### **After**
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
#### Performance checks (if applicable)
- [ ] I've tested on Android
- [ ] I've tested with a power user scenario
- [ ] I've instrumented key operations with Sentry traces for production
performance metrics
## **Pre-merge reviewer checklist**
- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Low risk UI data-source swap: the “Move mUSD” row now reads from the
canonical Money Account balance, which could only affect displayed copy
if the previous EVM-account-aggregated value differed or was undefined.
>
> **Overview**
> Updates the Add Money bottom sheet so the “Move mUSD” option displays
the **Money Account** fiat balance (via
`useMoneyAccountBalance().totalFiatFormatted`) instead of the previously
EVM-account-aggregated `useMusdBalance()` value, eliminating mismatches
with the header balance.
>
> Adjusts `MoneyAddMoneySheet` tests to mock the new hook and keep the
same behaviors for locale-prefixed amounts and the no-amount fallback
copy.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
88dd0bc. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 2e4b3d7 commit 9432aa0
2 files changed
Lines changed: 14 additions & 13 deletions
File tree
- app/components/UI/Money/components/MoneyAddMoneySheet
Lines changed: 10 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | | - | |
90 | | - | |
| 90 | + | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| |||
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
113 | | - | |
114 | | - | |
| 114 | + | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
122 | | - | |
123 | | - | |
| 123 | + | |
| 124 | + | |
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
0 commit comments