Add timesheet approval workflow (draft → submitted → approved/rejected) - #924
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
✅ End-to-end verification of the approval workflowRan the branch locally (backend with Approver queue → approve → member sees locked, approved entry Member is blocked from approver surfacesNo "Pending Approvals" nav item, and navigating directly to API guard checks (curl)Not covered: multi-member queues, |



Summary
Adds an end-to-end approval workflow for work entries: owners submit entries, approvers approve/reject them, and approved entries become immutable.
State machine
draft → submitted,rejected → submitted(resubmit)submitted → approved,submitted → rejected409withCannot <action> work entry with status '<status>'PUT/DELETEon anapprovedentry →403 Approved entries cannot be modifiedAPI changes
work_entries.status TEXT NOT NULL DEFAULT 'draft'(+ index);users.role TEXT NOT NULL DEFAULT 'member'/api/work-entries):POST /:id/submit— owner-scoped (user_email)POST /:id/approve,POST /:id/reject— approver-only, operate on any user's entryGET /pending-approvals— approver-only queue of allsubmittedentries across users (includesuser_email,client_name)requireApprovermiddleware inauth.jsreturns 403 unlessusers.role === 'approver'approverif the email is listed in theAPPROVER_EMAILSenv var (comma-separated, case-insensitive). Existing user rows are the source of truth afterwards./api/auth/loginand/api/auth/menow includerole; existing work-entry responses now includestatusFrontend
WorkEntriesPage: Status chip column, Submit button on draft/rejected rows, Edit/Delete disabled for approved rowsPendingApprovalsPage(route/pending-approvals, nav item) shown only to approvers, with Approve/Reject actionsapi/client.ts:submitWorkEntry,approveWorkEntry,rejectWorkEntry,getPendingApprovalsReviewer manual checks
APPROVER_EMAILSin the backend env before starting it; log in with a listed email to see the Pending Approvals nav/view. Roles are assigned at user creation only — an existingmemberrow staysmembereven if later added toAPPROVER_EMAILS(DB is in-memory, so a backend restart resets this)./api/work-entries/pending-approvals,/:id/approve,/:id/reject.Tests
Backend jest suite extended (182 passing, coverage ~87%): all valid transitions, every invalid transition (409), role enforcement (403), approved-entry immutability, pending-approvals queue.
Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/b9955f6683e243439999fc774759d8ad
Requested by: @sumitshatwara