Bug #412 — Contractor should not have JSA approve/return buttons
Issue: #412 Reporter: Kang-Supreeya Date: 2026-02-16 Version: Preview33 Severity: Medium Frequency: Always
Description
Contractor sees "Approve JSA" (อนุมัติ JSA) and "Return for Edit" (ส่งกลับแก้ไข) buttons on JSA documents. Contractors should never have these buttons — they are reviewer-only actions for WO/SO.
Related: #411 (WO/SO lost these same buttons — same root cause) Service Report: SR #014
Location
ผู้รับเหมา > Tasks > สร้างงาน > จัดเตรียม JSA
Bug Details
| Role | Expected | Actual |
|---|---|---|
| Contractor | No "อนุมัติ JSA" or "ส่งกลับแก้ไข" buttons | Both buttons visible |
Screenshot

Steps to Reproduce
- Login as Contractor
- Go to Tasks > สร้างงาน
- Select จัดเตรียม JSA and pick a project
- Open a JSA document
- Observe toolbar — approve and return buttons appear (should not)
Root Cause
Same as #411. The state label "co-review" was not recognized by the frontend, causing it to default to the Contractor-expected state — so the Contractor role incorrectly passed the role check and saw reviewer commands.
Fix Applied
| Layer | Change |
|---|---|
| Backend | Added VisibleToRoleIds = [WorkOwner, SafetyOfficer] on review commands, [Contractor] on preparation commands |
| Frontend | Toolbar checks visibleToRoleIds from backend commands, blocking Contractor from seeing review commands |
PR: #414 Version: Preview34
What to Test
| # | Test Case | Status |
|---|---|---|
| 1 | Contractor opens JSA task → No "อนุมัติ JSA" button | 🔍 In Review |
| 2 | Contractor opens JSA task → No "ส่งกลับแก้ไข" button | 🔍 In Review |
| 3 | Contractor only sees Submit and Cancel buttons during preparation | 🔍 In Review |