Skip to content

[CP Stg] Fix overlapping submit buttons after cancelling PDF generation - #105297

Merged
jasperhuangg merged 6 commits into
mainfrom
fix/submit-pdf-cancel-animation
Oct 28, 2026
Merged

jasperhuangg merged 6 commits into
mainfrom
fix/submit-pdf-cancel-animation

Conversation

@roryabraham

@roryabraham roryabraham commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Cancelling Submit via PDF could leave the old green loading button visible beside the restored Submit dropdown. #105222 starts cleanup earlier, but the Reanimated exiting animation still outlives the fading modal.

Replace that unmount-driven animation with Reanimated 4 CSS keyframes. The mounted submission animation owns the shrink/fade and finishes through onCSSAnimationEnd; cancelling unmounts the old view immediately instead of animating a retained clone. Keep the Submitted display delay in CSS and respect reduced motion.

Removed inappropriate/unnecessary effects as part of the refactor:

  • Scope animation state to a child keyed by report and submission mode, eliminating prop-driven reset Effects and redundant width measurement
  • DEW loading follows backend metadata
  • failure acknowledgement remains an external Onyx action without briefly showing Submitted.

Add a component regression that renders the real Reanimated web exit implementation. It failed before the fix because both buttons remained in the DOM. Additional cases cover completion callbacks, cancellation, reduced motion, restarting, report changes, and DEW success/failure state.

AI tests
  • Passed: 47 targeted Jest tests across five suites:

    npm test -- --runInBand \
      tests/ui/components/AnimatedSubmitButtonTest.tsx \
      tests/ui/components/SubmitActionButtonTest.tsx \
      tests/unit/components/FileDownloadModalWrapperTest.tsx \
      tests/unit/hooks/useReportPDFDownloadModalTest.tsx \
      tests/unit/hooks/useExpensifyCardStatementPDFDownloadModalTest.tsx
  • Passed: changed-file lint, spelling, React Compiler compliance, scoped oxfmt --check, and agents sync --check.

  • Full typecheck remains blocked by pre-existing camera, Onyx, and tooling dependency/type errors; no diagnostics refer to either changed file.

  • Playwright desktop Chrome: three unthrottled dismissals showed zero overlapping frames. Also verified the normal animated completion, reduced-motion completion, and cancellation during the CSS fade.

  • The browser used this branch's local frontend with the staging API through a browser-only asset override; this is not a staging deployment.

  • Environment limitation: the browser console contains dev-server HMR WebSocket errors and staging PDF-fetch CORS errors. No clean-console or PDF-content-validation claim is made. Native/mobile, offline, and high-traffic-account verification have not been performed.

Reproduction/verification flow used by the AI:

  1. Open a draft report in a Submit-type workspace created through "Submit expenses to my employer" onboarding.
  2. Select Submit via PDF.
  3. Click outside the Generate PDF modal while it still says "Please wait while we generate the PDF."
  4. Confirm the report returns to Draft and the loading button is removed immediately, with only the restored Submit via PDF button visible. That label is the remembered submission preference, not a stuck loading state.

Fixed Issues

$ #105206

Tests

  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create an expense.
  4. Open the expense.
  5. Click Submit dropdown button.
  6. Click Submit via PDF.
  7. Quickly click outside Generate PDF modal to dismiss it.
  8. Verify green loading button disappears and is replaced by Submit button.
  • Verify that no errors appear in the JS console

Offline tests

None.

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 there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • 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 a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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
issue-105206-approved-fix.webm

Use the real Reanimated web exit implementation rather than the shared
mock, which removes exiting views immediately. The regression assertion
fails before the fix because the loading button survives beside the
restored submit dropdown.
Run the completed-submission shrink/fade explicitly instead of using an
exiting layout animation. Unmounting on PDF cancellation must remove the
loader immediately rather than retaining it beside the restored button.
Cancel in-flight timing animations during cleanup.

The previously failing real-web-renderer regression now passes. Add
coverage for delayed cancellation and stopping a mounted button.

Verified 40 targeted Jest tests and Playwright cancellation/completion.
Changed-file lint, spelling, and React Compiler checks pass. Full
typecheck has existing camera, Onyx, and tooling dependency failures.
Replace the timing-based shrink/fade with Reanimated CSS keyframes and
onCSSAnimationEnd. Cancelled submissions unmount immediately without
retaining an exiting view or invoking the completion callback. Honor
reduced motion with a zero-duration CSS animation.

Keep the real-web exit regression and add CSS callback, reduced-motion,
and mid-animation cancellation coverage. Enable fake timers explicitly
because the shared Jest setup restores real timers.

Verified 43 targeted tests and Playwright cancellation, normal completion,
reduced-motion completion, and cancellation during the CSS fade. Lint,
spelling, formatting, and React Compiler checks pass. Full typecheck still
has baseline dependency errors, with none in changed files.
Reset animation state by mounting a keyed active child instead of
copying the running prop into state in an Effect. Derive DEW loading
from metadata, remember failures during render, and move the Submitted
display delay into CSS. Remove redundant width measurement and ref reads.

Keep Effects only for a cancellable loading timer and acknowledgement of
failed submissions in the external Onyx store.

Add restart, report-switch, DEW loading, and failure-acknowledgement
coverage. All 47 targeted tests pass. Playwright verifies cancellation,
completion, reduced motion, and cancellation during the fade. Oxfmt,
lint, spelling, and React Compiler checks pass. Full typecheck retains
baseline dependency errors with none in changed files.
@roryabraham
roryabraham requested a review from a team October 28, 2026 21:30
@roryabraham roryabraham changed the title Fix overlapping submit buttons after cancelling PDF generation [CP Stg] Fix overlapping submit buttons after cancelling PDF generation Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

This comment has been minimized.

The real-web animation regression imports @testing-library/dom directly,
but the package was only available as a transitive dependency. Declare
the already-locked 10.4.2 version as a dev dependency so Knip and npm ci
recognize the import without changing dependency resolutions.

Knip comparison introduces zero new findings; 47 targeted tests pass.
@roryabraham
roryabraham marked this pull request as ready for review October 28, 2026 21:39
@roryabraham
roryabraham requested a review from a team as a code owner October 28, 2026 21:39
@melvin-bot
melvin-bot Bot requested review from daledah and removed request for a team October 28, 2026 21:40
@melvin-bot

melvin-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-28T21:46:02.830641Z 3efd13e 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.

</Animated.View>
)}
{!isAnimationRunning && (
<Animated.View style={[styles.justifyContentCenter, {height: variables.componentSizeNormal}]}>

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.

❌ UI-3 (docs)

The outer container passes an inline style object literal {height: variables.componentSizeNormal} to the style prop. This is a static value (a design token), not an animated reanimated style nor a value that must be computed at render time, so it belongs in the shared style system. Inline object literals create a new object every render and bypass theming. A styles.componentSizeNormal (height + width) helper already exists in src/styles/index.ts.

Move the static height into the style system instead of an inline object. For example, add a height-only token to styles and reference it:

<Animated.View style={[styles.justifyContentCenter, styles.componentHeightNormal]}>

where componentHeightNormal is defined in src/styles/index.ts as {height: variables.componentSizeNormal}.


Reviewed at: 3efd13e | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

@mkhutornyi

mkhutornyi commented Oct 28, 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
Screen.Recording.2026-10-28.at.10.11.38.PM.mov
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-10-28.at.10.04.58.PM.mov

</Animated.View>
)}
{!isAnimationRunning && (
<Animated.View style={[styles.justifyContentCenter, {height: variables.componentSizeNormal}]}>

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.

Outer Animated.View no longer animates anything

The animation moved to the inner view and containerStyles is gone, so this wrapper only has static styles.

Use a plain View.

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.

we can fix this in a cleanup @roryabraham

View: jest.fn((props: React.ComponentProps<typeof WebView>) => <WebView {...props} />),
},
// Jest does not compile app worklets. Keep the real web hook with explicit dependencies.
useAnimatedStyle: (updater: Parameters<typeof actual.useAnimatedStyle>[0]) => actual.useAnimatedStyle(updater, [updater]),

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.

Test still mocks useAnimatedStyle

The component no longer calls useAnimatedStyle, so this mock does nothing.

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.

we can fix this in a cleanup @roryabraham

Comment thread package.json Resolved
@m-natarajan

Copy link
Copy Markdown

issue not reproduce in web and iOS, v9.5.24-5 PR:105297 Ad-Hoc (Step 8: green loading button disappears and is replaced by Submit PDF button, Not Submit button)

Screen.Recording.2026-10-29.at.4.49.16.AM.mov
ScreenRecording_10-29-2026.04-52-43_1.MP4

@mkhutornyi

Copy link
Copy Markdown
Contributor

Step 8: green loading button disappears and is replaced by Submit PDF button, Not Submit button

If this is expected behavior, all good

@mkhutornyi mkhutornyi 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.

Please check nab comments

@mkhutornyi

mkhutornyi commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

On Android:

  • loading button disappears and More dropdown button takes full width briefly.
  • And then Submit via PDF button shows, reducing More button width back.

Not blocking on this though

Screen.Recording.2026-10-28.at.10.12.45.PM.mov

@jasperhuangg
jasperhuangg merged commit 9387bba into main Oct 28, 2026
64 of 71 checks passed
@jasperhuangg
jasperhuangg deleted the fix/submit-pdf-cancel-animation branch October 28, 2026 22:37
OSBotify pushed a commit that referenced this pull request Oct 28, 2026
…tion

[CP Stg] Fix overlapping submit buttons after cancelling PDF generation

(cherry picked from commit 9387bba)

(cherry-picked to staging by jasperhuangg)
@OSBotify OSBotify added the CP Staging marks PRs that have been CP'd to staging label Oct 28, 2026
@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

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

@github-actions

Copy link
Copy Markdown
Contributor

@os-botify

os-botify Bot commented Oct 28, 2026

Copy link
Copy Markdown

🔁 Filed a Staging retest request for deploy blockers #105206 after this PR was cherry-picked to staging.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Cherry-picked to staging by https://github.com/jasperhuangg in version: 9.5.24-8 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed. This PR fixes an animation glitch where the old loading button stayed visible after you dismissed the Generate PDF modal. The app now behaves the way users already expect, so no article sentence is wrong.


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):

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Cherry-picked to staging by https://github.com/jasperhuangg in version: 9.5.25-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed. This PR fixes an animation glitch where the old loading button stayed visible after you dismissed the Generate PDF modal. The app now behaves the way users already expect, so no article sentence is wrong.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.5.25-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

CP Staging marks PRs that have been CP'd to staging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants