Skip to content

Add company rules PDF upload to workspace overview #86436

@MelvinBot

Description

@MelvinBot

Objective

Add frontend support for workspace admins to upload a company rules PDF to the workspace overview page. Non-admin members should be able to view/download the PDF.

This is the frontend (Expensify/App) counterpart to Expensify/Expensify#610806, which tracks the full feature including backend changes.

Design mocks: https://github.com/Expensify/Expensify/issues/610806#issuecomment-4075079607
Figma: https://www.figma.com/design/b6wtJw7oSN5stm1Km60yYm/PDF-and-Text-Field-Expense-Policy?node-id=28-13244


Frontend Changes Required

1. Add companyRulesPdfURL to the Policy type

  • src/types/onyx/Policy.ts — Add companyRulesPdfURL?: string field to the Policy type

2. Add write commands and API parameter types

  • src/libs/API/types.ts — Add UPDATE_WORKSPACE_RULES_DOCUMENT and DELETE_WORKSPACE_RULES_DOCUMENT to WRITE_COMMANDS
  • Add corresponding parameter types for both commands

3. Add Policy action functions

  • src/libs/actions/Policy/Policy.ts — Add updateWorkspaceRulesDocument() and deleteWorkspaceRulesDocument() action functions
  • Follow the optimistic update pattern used by updateWorkspaceAvatar (optimisticData sets the URL immediately, failureData reverts, successData confirms)

4. Update WorkspaceOverviewPage.tsx

Add a new "Company rules" section to the workspace overview page:

Admin view (empty state):

  • Drag-and-drop zone using existing DragAndDrop component + AttachmentPicker for click-to-upload
  • Text: "Drag and drop a PDF of your company rules" with a file picker fallback
  • Only accept PDF files; show error for non-PDF uploads

Admin view (PDF uploaded):

  • Show the PDF filename with "Replace" and "Remove" actions
  • "Replace" opens the file picker again
  • "Remove" calls deleteWorkspaceRulesDocument()

Employee view (PDF exists):

  • Show a read-only "Company rules" item that opens/downloads the PDF

Employee view (no PDF):

  • Don't show the section at all

5. Optional: Text description field

The existing customRules field (behind BETA_CUSTOM_RULES beta) can serve as the optional text description shown in the designs. Depending on product direction, this may either:

  • Reuse the existing customRules field directly
  • Use a new separate field if the text should be independent from AI-enforced rules

Existing Components to Reuse

  • AttachmentPicker (src/components/AttachmentPicker/) — Cross-platform file picker, already supports PDF selection
  • DragAndDrop (src/components/DragAndDrop/) — Web drag-and-drop support
  • WorkspacePageWithSections — Layout wrapper already used by WorkspaceOverviewPage
  • MenuItemWithTopDescription — Used for other workspace settings display

Backend Dependency

The backend API commands (UpdateWorkspaceRulesDocument, DeleteWorkspaceRulesDocument) and the companyRulesPdfURL policy field are tracked in Expensify/Expensify#610806. Frontend work can begin with optimistic patterns and be connected once the backend is ready.

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions