Skip to content

Conversation

sahar-fehri
Copy link
Contributor

@sahar-fehri sahar-fehri commented Oct 13, 2025

Description

PR to fix hiding tokens with zero balance when the setting is enabled.

Open in GitHub Codespaces

Changelog

CHANGELOG entry: Fixed a bug causing users to still see tokens with zero balance when the setting "hideTokensWithZeroBalance" is enabled.

Related issues

Fixes: #36764

Manual testing steps

  1. Import any token with zero balance
  2. Notice that the balance 0.00 is displayed on the main asset list
  3. Go to settings and enable setting "hide tokens with zero balance"
  4. The token should now be removed from the list.

Screenshots/Recordings

Before

After

Screen.Recording.2025-10-13.at.16.23.15.mov

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • 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.

Note

Hides zero-balance tokens in the asset list when the setting is enabled, including for multichain accounts.

  • Assets list (multichain):
    • Apply getShouldHideZeroBalanceTokens to filter out assets with balance === '0' before mapping/sorting in ui/components/app/assets/token-list/token-list.tsx.
    • Wire up selector via useSelector to honor the user setting across networks.

Written by Cursor Bugbot for commit 1e07196. This will update automatically on new commits. Configure here.

@sahar-fehri sahar-fehri requested a review from a team as a code owner October 13, 2025 15:16
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

cursor[bot]

This comment was marked as outdated.

@metamaskbot
Copy link
Collaborator

metamaskbot commented Oct 13, 2025

✨ Files requiring CODEOWNER review ✨

💎 @MetaMask/metamask-assets (1 files, +24 -14)
  • 📁 ui/
    • 📁 components/
      • 📁 app/
        • 📁 assets/
          • 📁 token-list/
            • 📄 token-list.tsx +24 -14

@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: 2d27454 | Date: 10/13/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±76ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 728ms (±74ms) 🟢 | historical mean value: 737ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 75ms (±10ms) 🟢 | historical mean value: 77ms ⬇️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 76ms 997ms 1.33s 1.30s 1.33s
domContentLoaded 728ms 74ms 686ms 1.01s 989ms 1.01s
firstPaint 75ms 10ms 56ms 152ms 88ms 152ms
firstContentfulPaint 75ms 10ms 56ms 152ms 88ms 152ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [2d27454]
UI Startup Metrics (1229 ± 64 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1229111414986412551349
load105595612415410821148
domContentLoaded104895112255410751142
domInteractive17134061737
firstPaint634140123743310721137
backgroundConnect25423740018256272
firstReactRender25184672642
getState13497121527
initialActions50819515
loadScripts80171293349829888
setupStore95253916
WebpackHomeuiStartup8277101089728421016
load63558493174637863
domContentLoaded62757892374633853
domInteractive161165101446
firstPaint17856884180175609
backgroundConnect21104662431
firstReactRender27166293241
getState841931014
initialActions3014247
loadScripts62557691271631842
setupStore84263913
FirefoxBrowserifyHomeuiStartup14391249196914214681812
load1226107014848812731395
domContentLoaded1226107014848812731394
domInteractive1053429855111246
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3218113183373
firstReactRender30255753241
getState11322027527
initialActions7018924224
loadScripts1203105114668512561376
setupStore10414016741
WebpackHomeuiStartup15641370202013216151881
load1360121616869514241538
domContentLoaded1359121516869514231537
domInteractive1013137467101324
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3219117173583
firstReactRender332679103545
getState9214320624
initialActions40376215
loadScripts1334120116679214031511
setupStore12413617947
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 48 Bytes (0%)
  • ui: 92 Bytes (0%)
  • common: -27.29 KiB (-0.33%)

juanmigdr
juanmigdr previously approved these changes Oct 14, 2025
Copy link
Member

@juanmigdr juanmigdr left a comment

Choose a reason for hiding this comment

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

Approved with comment

cursor[bot]

This comment was marked as outdated.

juanmigdr
juanmigdr previously approved these changes Oct 14, 2025
@sahar-fehri sahar-fehri enabled auto-merge October 14, 2025 08:46
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Token List Filter Fails On Setting Toggle

The useMemo dependency array is missing shouldHideZeroBalanceTokens. When the "hide zero balance tokens" setting is toggled, the token list doesn't recompute, leading to stale filtering results until another dependency changes.

ui/components/app/assets/token-list/token-list.tsx#L134-L147

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
isEvm,
evmBalances,
multichainAssets,
networksToShow,
currentNetwork.chainId,
tokenSortConfig,
isMultichainAccountsState2Enabled,
accountGroupIdAssets,
// newTokensImported included in deps, but not in hook's logic
newTokensImported,
allEnabledNetworksForAllNamespaces,
]);

Fix in Cursor Fix in Web


@sahar-fehri sahar-fehri requested a review from juanmigdr October 14, 2025 09:32
@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: 1e07196 | Date: 10/14/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.06s (±74ms) 🟡 | historical mean value: 1.05s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 745ms (±72ms) 🟢 | historical mean value: 737ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 79ms (±14ms) 🟢 | historical mean value: 77ms ⬆️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.06s 74ms 1.02s 1.41s 1.29s 1.41s
domContentLoaded 745ms 72ms 706ms 1.08s 958ms 1.08s
firstPaint 79ms 14ms 64ms 204ms 88ms 204ms
firstContentfulPaint 79ms 14ms 64ms 204ms 88ms 204ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [1e07196]
UI Startup Metrics (1235 ± 64 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1235113214456412721371
load106496312445810961184
domContentLoaded105995812385810901178
domInteractive1913124131840
firstPaint67981124342510761137
backgroundConnect2532392757256267
firstReactRender25194852637
getState13692121535
initialActions50345615
loadScripts81171297756847913
setupStore951631114
WebpackHomeuiStartup8176981142778281014
load62957796473633857
domContentLoaded62257195571628840
domInteractive15115581434
firstPaint17557911183169686
backgroundConnect21104982436
firstReactRender26166483134
getState944051014
initialActions2029346
loadScripts61956994569627829
setupStore84212912
FirefoxBrowserifyHomeuiStartup14001202189712314641660
load1199104014418912591366
domContentLoaded1198103914408912581366
domInteractive97332795196243
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2920108133242
firstReactRender30256063242
getState7313113513
initialActions30305213
loadScripts1177102114198812361339
setupStore9413915627
WebpackHomeuiStartup16091340202812216621860
load1393119016658714441558
domContentLoaded1393119016658614431558
domInteractive1043139261110193
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3417119183784
firstReactRender372782133878
getState9316118618
initialActions40539225
loadScripts1367117516428314161520
setupStore11410316951
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 85 Bytes (0%)
  • common: 10 Bytes (0%)

Copy link
Member

@juanmigdr juanmigdr left a comment

Choose a reason for hiding this comment

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

Should we have a simple test?

});
return assets
.filter((asset) => {
if (shouldHideZeroBalanceTokens && asset.balance === '0') {
Copy link
Member

Choose a reason for hiding this comment

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

🤔 isnt there a numeric value we can compare to? Instead of string?

@sahar-fehri sahar-fehri added this pull request to the merge queue Oct 14, 2025
Merged via the queue into main with commit d51fe94 Oct 14, 2025
170 checks passed
@sahar-fehri sahar-fehri deleted the fix/fix-hide-zero-balance-setting-for-asset-list branch October 14, 2025 10:06
@github-actions github-actions bot locked and limited conversation to collaborators Oct 14, 2025
@metamaskbot metamaskbot added the release-13.6.0 Issue or pull request that will be included in release 13.6.0 label Oct 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.6.0 Issue or pull request that will be included in release 13.6.0 size-S team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Hide tokens without balance still displays tokens with 0 balance when enabled from setting

4 participants