Skip to content

Add workspace rules PDF document upload, view, and management UI#87684

Draft
ishpaul777 wants to merge 2 commits intoExpensify:mainfrom
ishpaul777:ishpaul/workspace-rules-document-upload
Draft

Add workspace rules PDF document upload, view, and management UI#87684
ishpaul777 wants to merge 2 commits intoExpensify:mainfrom
ishpaul777:ishpaul/workspace-rules-document-upload

Conversation

@ishpaul777
Copy link
Copy Markdown
Contributor

@ishpaul777 ishpaul777 commented Apr 11, 2026

Summary

Adds frontend support for workspace admins to upload, replace, view, and delete a PDF document on the workspace overview page. Non-admins can view/download the document.

Changes

  • WorkspaceOverviewPage.tsx — Added PDF document section with AttachmentPicker for upload, PDFThumbnail for preview, three-dots menu for replace/delete, and tap-to-view via AttachmentModalScreen
  • Policy.ts (actions) — Added updateWorkspaceRulesDocument, deleteWorkspaceRulesDocument actions with optimistic/failure/finally Onyx updates. Uses file.uri (local blob) for optimistic display (same pattern as workspace avatar)
  • PolicyUtils.ts — Added getPolicyDocumentSourceURL utility that constructs the authenticated streaming URL with cache-busting parameter, or returns local blob URIs directly
  • WorkspaceDocumentModalContent.tsx — New modal content component (mirrors WorkspaceAvatarModalContent) for viewing the PDF in the attachment modal
  • Navigation — Added WORKSPACE_DOCUMENT route and screen following the WORKSPACE_AVATAR pattern
  • Types — Added policyDocumentURL to Policy.ts type, new API parameter types

Key decisions:

  • Optimistic updates use file.uri (local blob URL) for instant display — same proven pattern as workspace avatar uploads
  • Cache-busting via &cacheBuster= parameter encoding the full policyDocumentURL — ensures the streaming URL is unique per PDF version, preventing stale browser cache
  • Dedicated WORKSPACE_DOCUMENT route instead of reusing REPORT_ATTACHMENTS — workspace documents are not report attachments
  • PDF served through authenticated api.php streaming endpoint (not direct CDN) — required for CORS compatibility with pdfjs and for privacy (private S3 bucket)

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/610806

Tests

  • Verify this pull request passes all automated checks

Manual tests:

  1. As admin: Upload a PDF → verify thumbnail appears immediately
  2. Tap thumbnail → verify PDF opens in attachment modal
  3. Replace PDF with a different one → verify new thumbnail/content appears immediately
  4. Delete PDF → verify it disappears
  5. Upload a non-PDF → verify error
  6. As non-admin member → verify PDF is viewable but upload/delete options are hidden

Allow workspace admins to upload, replace, and remove a PDF document
on the workspace overview page. Non-admins can view and download it.
PDFs are stored in a private S3 bucket and served through an
authenticated streaming endpoint.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2026

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 Δ
src/SCREENS.ts 100.00% <ø> (ø)
src/libs/API/types.ts 100.00% <ø> (ø)
src/libs/Navigation/AppNavigator/AuthScreens.tsx 83.14% <100.00%> (+0.19%) ⬆️
...ateRootStackNavigator/GetStateForActionHandlers.ts 28.88% <ø> (ø)
src/libs/Navigation/linkingConfig/config.ts 76.92% <ø> (ø)
src/ROUTES.ts 16.32% <0.00%> (-0.02%) ⬇️
src/pages/media/AttachmentModalScreen/index.tsx 25.00% <0.00%> (-2.78%) ⬇️
src/libs/PolicyUtils.ts 61.72% <0.00%> (-0.40%) ⬇️
...dalScreen/routes/WorkspaceDocumentModalContent.tsx 0.00% <0.00%> (ø)
src/pages/workspace/WorkspaceOverviewPage.tsx 0.00% <0.00%> (ø)
... and 1 more
... and 13 files with indirect coverage changes

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.

1 participant