Skip to content

[Payment due @situchan] Remove victory-native tickCount patch - #104659

Merged
roryabraham merged 26 commits into
Expensify:mainfrom
s77rt:victory-native-remove-tickCount-patch
Oct 26, 2026
Merged

roryabraham merged 26 commits into
Expensify:mainfrom
s77rt:victory-native-remove-tickCount-patch

Conversation

@s77rt

@s77rt s77rt commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Explanation of Change

Removed the tickCount patch. When tickCount is > 0 then the drawn labels consume same allocated window size that the chart would be displayed in, this makes the chart looks smaller. I'm not sure if that's the intended behavior but that was the case even before the 42.0.1 upgrade, back then we just used to pass tickCount=0 so this logic was not hit.

I found this prop leftAxisLabelPadding that we are using and it follows similar pattern (altering padding) so I guess we can move forward with that solution. Just worth noting that if that "shared allocation" is bug upstream then we can easily just remove that padding altering logic.

The logic is pretty straightforward:

  1. Compute axis size
  2. Subtract axis size from padding

Fixed Issues

#91883
PROPOSAL:

Tests

(Not for QA)

Follow the QA tests then test follow both tests in #90253 and #91659

  • Verify that no errors appear in the JS console

Offline tests

n/a

QA Steps

  • Have an account with some expenses from different merchant and categories
  1. Open App
  2. Go to Insights tab
  3. Verify charts load correctly
Screenshot 2026-10-21 at 11 07 43 PM
  • 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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

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 Δ
...ctoryChartRenderer/context/VictoryChartContext.tsx 96.00% <100.00%> (ø)
...ryChartRenderer/utils/computeDynamicChartHeight.ts 90.00% <100.00%> (ø)
...ryChartRenderer/parsers/processVictoryChartTree.ts 70.83% <50.00%> (-4.17%) ⬇️
.../VictoryChartRenderer/parsers/victoryAxisParser.ts 68.33% <57.14%> (-3.10%) ⬇️
...erers/VictoryChartRenderer/utils/resolvePadding.ts 13.63% <13.63%> (-61.37%) ⬇️
... and 142 files with indirect coverage changes

@s77rt

s77rt commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

@MelvinBot Please review. I think I'm missing some logic in computing the axisSize can you spot that one out

@MelvinBot

Copy link
Copy Markdown
Contributor

The x-axis formula has the 2× on the wrong term. victory-native reserves labelHeight + 2 * labelOffset, not 2 * lineHeight + labelOffset (transformInputData.ts:211-214). It also measures labelHeight as lines × fontSize, not Skia's ascent + descent + leading (textLayout.ts:24-38). Suggested fix for victoryAxisParser.ts:29:

const maxLines = Math.max(...labels.map((label) => String(label).split(/\r\n|\r|\n/).length));
return maxLines * font.getSize() + 2 * (labelOffset ?? 0);

computeAxisSize is also missing victory's gate. victory reserves no space unless tickCount > 0. Because {...XAxisDefaults, ...xAxis} lets an explicit undefined override the default of 5, a chart with no tickcount and no tickvalues reserves nothing. The PR still subtracts from its padding.

Two padding bugs outside computeAxisSize:

  1. Numeric padding loses the compensation. For padding={40}, the parser assigns a new object to rootProcessedResult.padding. But processVictoryChartTree.ts:134 returns the local padding variable, which still holds 40. Only object padding works, because it mutates the shared object.
  2. The left axis is compensated twice. padding.left becomes P - A, then resolvePadding.ts:14 applies min(P - A, A + 32), and victory reserves another A. When P is large, the labels get 2A + 32 instead of A + 32. Clamp first, then subtract: min(P, A + 32) - A.
Other notes
  • Your PR TODOs (overflow, center anchor): these don't belong in axisSize. victory doesn't reserve space inside the window for edge labels that overflow sideways or for half-height overflow at the top or bottom. The padding still has to cover them, so subtracting them would clip the labels.
  • Measured labels vs drawn labels: victory measures only the downsampled ticks (downsampleTicks(tickValues, tickCount)), but labelsForMeasurement (L56) uses every tick value. When tickCount < tickValues.length, the PR can overestimate the width. This is minor.
  • Rotated labels: if labelRotate is ever supported, victory reserves extra space for it (L178-187). The parser doesn't set it today.

view run

@s77rt
s77rt marked this pull request as ready for review October 22, 2026 16:17
@s77rt
s77rt requested review from a team as code owners October 22, 2026 16:17
@melvin-bot
melvin-bot Bot requested review from garrettmknight and removed request for a team October 22, 2026 16:17
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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-26T11:58:21.818058Z d3b4793 Manual request
ℹ️ 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.

@melvin-bot
melvin-bot Bot requested review from Beamanator and removed request for a team October 22, 2026 16:17
@melvin-bot

melvin-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

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

@s77rt
s77rt requested a review from situchan October 26, 2026 07:22
@situchan

Copy link
Copy Markdown
Contributor

Left padding now shrinks on vertical charts too

main only measured the label width for a horizontal chart's category axis. Now every left axis is measured, so min(P, labelWidth + 32) also cuts the backend's left padding on vertical charts. monthly-spend still matches main only because its labels up to $2,000 nearly fill the 96px padding. With shorter labels the plot starts further left than on main.

  1. Have a chat message with a vertical "Monthly spend" chart like monthly-spend.xml, but with a small y range such as tickformat="['$0','$100','$200','$300','$400','$500']"
  2. Open that chat
  3. Compare the gap between the card's left edge and the $0 grid line with main

Expected: Same as main. The plot starts 96px from the left edge, as the backend set it
Actual: The plot starts about 10px further left

Suggested Fix: only shrink the left padding for the horizontal chart's category axis, as main did (for example a flag returned from the !isDependentAxis && isHorizontal branch and checked here).

@MelvinBot

@MelvinBot

Copy link
Copy Markdown
Contributor

Confirmed. The left clamp should run only for horizontal charts. At resolvePadding.ts:32-34, min(P, A + 32) now applies to every left axis. Main applied it only to the horizontal chart's category axis.

With the monthly-spend style (11px font, 28px label offset):

  • $2,000 labels give A ≈ 61, so the padding is clamped to about 93px. The plot moves about 3px, which is too small to see.
  • $500 labels give A ≈ 50, so the padding is clamped to about 82px. The plot starts about 14px further left than on main. This matches the roughly 10px you measured.

Suggested fix: pass isHorizontal into resolvePadding from processVictoryChartTree.ts:158, then gate the clamp on it:

if (isHorizontal && leftAxisSize && resolvedPadding.left) {
    resolvedPadding.left = Math.min(resolvedPadding.left, leftAxisSize + LEFT_AXIS_LABEL_PADDING);
}

You don't need a separate flag. In a horizontal chart, the dependent axis always goes to the top or bottom, so the only left axis is the category axis from the !isDependentAxis && isHorizontal branch. Keep the -= leftAxisSize subtraction at L37-L39 for all charts. Vertical charts still need it, because victory-native reserves the label width inside the window.

I can't push this change because I'm not an assignee on this PR. s77rt can apply it, or add me as an assignee and ask me to.


view run

@situchan

Copy link
Copy Markdown
Contributor

@codex review
@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

The latest changes fix the earlier blockers. One small inconsistency is left. tickCount now falls back to 0, the golden matches main byte for byte, and the left clamp runs only on horizontal charts, as on main.

Remaining issue: dynamic height adds axis sizes that the padding never subtracted. The parser now stores bottomAxisSize and topAxisSize even when tickCount is 0. resolvePadding.ts:44-49 correctly skips those sizes. But VictoryChartContext.tsx:56-57 still passes them to computeDynamicChartHeight.

This affects a horizontal chart whose dependent axis has tickformat but no tickvalues. If it has fewer than 5 rows, those rows render taller than the reference rows. No current fixture has this shape, so this is not blocking.

Suggested fix: pass only the sizes that resolvePadding actually subtracted. For example, use xAxis?.tickCount ? bottomAxisSize : undefined, or return the applied sizes from resolvePadding so the gate lives in one place.

Nits
  • resolvePadding.ts:38-43 gates both the left and right subtraction on yAxis[0]. A chart with both a left and a right y-axis would use the first axis's tickCount for both. Matching each axis by axisSide avoids that. Also, yAxis?.[0]?.tickCount is safer than yAxis?.[0].tickCount.
  • The subtractions still have no Math.max(0, …) floor. If an authored padding is smaller than its labels, the padding goes negative and the labels are drawn past the canvas edge. No current fixture hits this.

view run

@MelvinBot

Copy link
Copy Markdown
Contributor

I found one new regression: vertical charts with text categories lose all x-axis labels. This happens when the independent axis has no tickvalues and no tickcount, and the bar x values are strings (for example, {x: 'Travel', y: 1080}).

Victory web also shows every category in this case. No current fixture uses this shape, and I couldn't confirm whether Concierge sends it. I traced this in code but couldn't render it here.

Suggested fix: after the series data is merged in processVictoryChartTree, check the x axis. If it has no tickValues and the x values are strings, set tickCount to the category count. Also measure those strings for bottomAxisSize.

Other differences from main
  • Minor, new: a numeric padding on a horizontal chart now gets the left clamp. Main clamped only object padding (main resolvePadding.ts:11). Now padding={150} becomes min(150, labelWidth + 32) on the left. No fixture uses this shape.
  • Still open from my last review: dynamic height still adds the bottom and top axis sizes when tickCount is 0 (VictoryChartContext.tsx:56-57). Also, resolvePadding.ts:38-49 can make a side negative when that side's padding is smaller than its axis labels.
  • Checked and unchanged: all 9 fixture shapes. These include axes with tickvalues, the horizontal category axis without tickvalues, pie charts with hidden axes, and expand-modal scaling, which scales the font, label offset, and padding together.

view run

@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: d3b4793bec

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

@s77rt

s77rt commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

@situchan Please give this another review / test

@garrettmknight
garrettmknight removed their request for review October 26, 2026 19:25
@roryabraham
roryabraham merged commit 7bd57e2 into Expensify:main Oct 26, 2026
42 of 43 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

🚧 roryabraham 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/roryabraham in version: 9.5.24-1 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed. This PR removes a victory-native library patch and adjusts chart axis padding so Insights charts render at the right size, which is an internal layout fix that doesn't change any feature, label, or step described in docs/articles.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.5.24-8 🚀

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

Bundle Size Analysis (Sentry):

@melvin-bot

melvin-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown

🤖 Payment issue created: #105312

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.

5 participants