Skip to content

Expense policy - Protected pdf file is allowed and password modal appears repeatedly #89345

Closed

Description

@mitarachim

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.65-0
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #87684
Email or phone of affected tester (no customers): applausetester+sjdiosndjsois2jd@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.2 / Chrome
App Component: Workspace Settings

Action Performed:

Precondition:

  • Log in with Expensifail account.
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Overview.
  3. Scroll down to Expense policy.
  4. Click Choose file.
  5. Upload protected pdf file (attached below).
  6. Enter password [Test12345].
  7. Go to Members tab.
  8. Go back to Overview tab.
  9. Click Cancel on password modal.

Expected Result:

Protected pdf file should not be allowed.

Actual Result:

Protected pdf file is allowed.
Password modal appears after changing tab and back to Overview. It appears repeatedly after tapping Cancel.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7142472_1777600040918!Password_protected_Test12345.pdf

Bug7142472_1777600040908.8.mp4

View all open jobs on GitHub

Activity

  1. added
    DeployBlockerCash
    Daily
    Bug
    DeployBlocker
    on May 1, 2026
  2. melvin-bot commented on May 1, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #87684

  3. melvin-bot commented on May 1, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. github-actions commented on May 1, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  5. OSBotify commented on May 1, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #87684 - "Add workspace rules PDF document upload, view, and management UI" by @ishpaul777 (High confidence)
    Related Issues: None

    Recommendation: REVERT

    PR #87684 introduced the entire "Expense policy PDF document" feature in WorkspaceOverviewPage.tsx. The bug reproduces only on staging (it's a new feature not in production), and the fix requires changes to this App PR. Reverting it cleanly removes the broken functionality.

    Assigned: @ishpaul777 (PR author), @abzokhattab (approving reviewer), @lakchote (approving reviewer)
    Labels: DeployBlockerCash kept (frontend/App PR is the cause). DeployBlocker removed — no backend changes are required to fix this issue; the root cause is entirely in the App PR.

    Detailed Analysis

    Evidence

    Verification

    Root Cause

    updatePolicyRulesDocument accepts any valid PDF without checking for password protection. Once a password-protected PDF is stored as policy.rulesDocumentURL, the PDFThumbnail component rendered on the Overview page encounters the password requirement but has no onPassword handler registered — causing it to re-trigger the password prompt every time the component mounts (e.g., after switching tabs). Clicking Cancel does not clear the stored URL, so the modal reappears in a loop.

  6. removed
    DeployBlocker
    on May 1, 2026
  7. MelvinBot commented on May 1, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    There are two bugs here, both stemming from the workspace rules document upload flow (introduced in #87684) having no validation for password-protected PDFs:

    Bug 1 — Password-protected PDFs are accepted: handleRulesDocumentPicked passes the picked file directly to updatePolicyRulesDocument, which only checks that the file is a PDF (by MIME type / extension) but never checks for password protection. The file is uploaded as-is.

    The rest of the app already solves this: useFilesValidation renders an invisible PDFThumbnail with an onPassword callback that rejects password-protected PDFs with CONST.FILE_VALIDATION_ERRORS.PROTECTED_FILE when isValidatingReceipts is true. The rules document upload path does not use this hook at all.

    Bug 2 — Password modal reappears after Cancel: Because the password-protected PDF is stored as rulesDocumentURL, viewing it in WorkspaceDocumentModalContent renders a PDFView that detects the password and shows PDFPasswordForm. When the user navigates to another workspace tab and returns, the PDF viewer remounts and re-triggers password detection, causing the modal to reappear even after dismissing it.

    What changes do you think we should make in order to solve the problem?

    Validate the picked file for password protection before calling updatePolicyRulesDocument, using the same invisible-PDFThumbnail pattern already used by useFilesValidation:

    In WorkspaceOverviewPage.tsx, modify handleRulesDocumentPicked to first render an invisible PDFThumbnail for the picked file. If the onPassword callback fires, reject the file and show the existing PROTECTED_FILE error. Only proceed with updatePolicyRulesDocument if onLoadSuccess fires (confirming the PDF is not password-protected).

    This fixes both bugs: password-protected PDFs are blocked at upload time (Bug 1), so they never get stored as rulesDocumentURL and the password modal never appears (Bug 2).

    What alternative solutions did you explore? (Optional)

    An alternative would be to integrate the full useFilesValidation hook into the rules document upload flow. However, that hook is designed for multi-file receipt validation with error modals, which is heavier than needed here. The simpler approach of adding a targeted PDFThumbnail check in handleRulesDocumentPicked is more proportional to the single-file, single-purpose upload flow.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  8. added
    Reviewing
    on May 1, 2026
  9. IuliiaHerets commented on May 1, 2026

    @IuliiaHerets

    Chrome / v9.3.65-1
    Choose file option removed from Overview

    REC-20260501130029.mp4
  10. abzokhattab commented on May 1, 2026

    @abzokhattab
    Contributor

    Are protected pdf files part of the story @ishpaul777 i dont see it mentioned

  11. removed
    DeployBlockerCash
    on May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugEngineeringHourlyReviewing

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions