# Feedback Privacy Protection Guide

## Overview
The feedback/GRM system now implements **strict privacy controls** to protect submitter identity from training providers. This ensures safe, confidential reporting without fear of retaliation.

---

## Privacy Policy

### What Training Providers SEE:
✅ Reference code (e.g., GRM-2026-123456)
✅ Category (complaint/suggestion/question/appreciation)
✅ Subject line
✅ Description/feedback text
✅ Status (open/in progress/resolved)
✅ Dates (submitted, due, response times)
✅ Conversation thread (all responses)

### What Training Providers CANNOT SEE:
❌ Submitter name
❌ Submitter email
❌ Submitter phone number
❌ Submitter region/location

**Displayed as:** "Confidential" or "***@***"

### Who CAN See Personal Data:
✅ **Project Administrators** - Full access for investigation
✅ **M&E Officers** - Full access for case management
✅ **System Administrators** - Full access for oversight

### Who CANNOT See Personal Data:
❌ **Training Provider Staff** - Personal data hidden
❌ **TP Organization Admins** - Personal data hidden
❌ **TP Site Leads** - Personal data hidden

---

## User Interface Changes

### 1. Public Feedback Form

**Privacy Notice Added:**
```
🔒 Your privacy is protected

Your personal information (name, email, phone, region) is confidential 
and hidden from training providers. Only M&E administrators can see your 
identity. Training providers see only your feedback text, category, and 
reference number. This ensures you can report issues safely without fear 
of retaliation.
```

**Location:** Prominently displayed at the top of the form

### 2. Feedback List Page (TP View)

**Before:**
| Ref | Subject | Category | **Submitter** | Provider | Updated | Status |
|-----|---------|----------|---------------|----------|---------|--------|

**After:**
| Ref | Subject | Category | Provider | Updated | Status |
|-----|---------|----------|----------|---------|--------|

**Submitter column removed** for training provider users.

### 3. Feedback Detail Page (TP View)

**Before:**
- Submitter sidebar showing name, email, phone, region

**After:**
- Submitter sidebar **completely hidden** for TP users
- Admin/M&E users still see full submitter card

---

## Backend Implementation

### API Response Filtering

```typescript
// For TP users:
{
  submitterName: "Confidential",
  submitterEmail: "***@***",
  submitterPhone: null,
  region: null
}

// For Admin/M&E users:
{
  submitterName: "John Doe",
  submitterEmail: "john@example.com",
  submitterPhone: "+251912345678",
  region: "Addis Ababa"
}
```

### Role-Based Access Control

```typescript
const redactSubmitter = scope.role === "tp";
// Only TP role gets redacted data
// admin, pmu, world_bank, edi, etc. see full data
```

---

## Email Notifications

### New Feedback Alert (to TP Users)

**What's Included:**
- Reference code
- Category
- Subject
- Submitted date (NOT submitter name)
- Due date
- Days to respond

**What's NOT Included:**
- ❌ Submitter name
- ❌ Submitter contact details

**Footer Note:**
> "Submitter contact details are confidential and not included in this notification."

### Due Date Reminders (to TP Users)

**Same privacy protection:**
- NO personal information included
- Only reference, category, subject, dates
- Footer note about confidentiality

---

## Export Functions

### Summary Exports (PDF/DOCX)
- **Admin users:** No personal data in summary (by design)
- **TP users:** Same view (by design)

### Detailed Exports (CSV/PDF)

**For Admin/M&E Users:**
```csv
Reference,Category,Subject,...,Submitter Name,Submitter Email,Submitter Phone,Region,...
GRM-2026-001,complaint,...,John Doe,john@example.com,+251912345678,Addis Ababa,...
```

**For TP Users:**
```csv
Reference,Category,Subject,...,Submitter Name,Submitter Email,Submitter Phone,Region,...
GRM-2026-001,complaint,...,Confidential,***@***,N/A,N/A,...
```

**Logic:**
```typescript
// If export is filtered by providerId, redact personal data
const redactPersonalData = providerId !== null && providerId !== undefined;
```

---

## Testing Privacy Controls

### Test Scenario 1: TP User Views Feedback List
1. Log in as TP staff user
2. Navigate to Feedback / GRM
3. **Verify:** No "Submitter" column in table
4. **Verify:** Cannot see names or emails

### Test Scenario 2: TP User Views Feedback Detail
1. Click on any feedback item
2. **Verify:** No submitter sidebar visible
3. **Verify:** Can see conversation thread
4. **Verify:** Can respond to feedback

### Test Scenario 3: Admin User Views Same Feedback
1. Log in as admin/M&E user
2. Navigate to same feedback
3. **Verify:** Submitter sidebar IS visible
4. **Verify:** Full name, email, phone, region shown

### Test Scenario 4: TP User Exports Data
1. Log in as TP user
2. Export Detailed CSV
3. **Verify:** Personal data columns show "Confidential", "***@***", "N/A"

### Test Scenario 5: Admin Exports Data
1. Log in as admin user
2. Export Detailed CSV for all providers
3. **Verify:** Full personal data visible

### Test Scenario 6: Email Notifications
1. Submit new feedback via public form
2. Check TP user email notification
3. **Verify:** No submitter name or contact in email
4. **Verify:** Footer note about confidentiality

---

## Security Considerations

### Database Level
- ✅ Personal data stored in database (required for admin access)
- ✅ NOT encrypted at rest (not PII for encryption laws)
- ✅ Access controlled at application layer

### Application Layer
- ✅ Role-based filtering in API
- ✅ Data redacted before sending to frontend
- ✅ Frontend hides UI elements conditionally

### Export Security
- ✅ Exports respect user scope
- ✅ TP exports automatically redact
- ✅ Audit trail for all exports

---

## Compliance & Best Practices

### Whistleblower Protection
- ✅ Submitters can report safely
- ✅ No retaliation risk from providers
- ✅ M&E team coordinates responses

### Data Minimization
- ✅ TP users see only what's needed to respond
- ✅ Personal data accessible only to oversight roles

### Transparency
- ✅ Clear notice on public form
- ✅ Submitters know data is protected
- ✅ Privacy policy explained upfront

---

## Audit & Logging

All data access is logged:
- Who viewed feedback details
- Who exported reports
- When personal data was accessed

**Check audit logs:**
Admin → Audit Trail → Filter by feedback-related actions

---

## Future Enhancements (Optional)

Potential improvements for consideration:
- [ ] Database-level encryption for personal data fields
- [ ] Anonymization after case closure (configurable retention)
- [ ] "Privacy Shield" indicator for TP users
- [ ] Admin approval for TP viewing exceptions
- [ ] Automatic data purging after X months

---

## Troubleshooting

### TP User Says: "I can't see submitter name"
**Response:** ✅ Working as designed. This is a privacy feature to protect submitters.

### Admin Says: "Submitter info is hidden"
**Check:** Verify user role is `admin`, `pmu`, or `world_bank`, NOT `tp`.

### Export Shows Personal Data to TP User
**Check:** Ensure backend scope.providerId is set correctly when generating export.

### Email Contains Personal Data
**Check:** Email template should NOT include submitter name/contact fields.

---

## Training & Communication

### For Training Providers
**Message:**
> "You'll see feedback content and can respond, but submitter identity is confidential to protect them from retaliation. This ensures people feel safe reporting issues."

### For Submitters
**Message:**
> "Your personal information is never shared with training providers. Only M&E staff can see your identity, and they coordinate all responses to protect you."

### For Admin/M&E
**Message:**
> "You have full access to submitter details for case management. Never share personal information with training providers. Always coordinate responses through the system."

---

## Legal & Ethical Considerations

### Grievance Mechanism Standards
✅ **Confidentiality** - Personal data protected from subjects of complaint
✅ **Non-Retaliation** - Structural protection for whistleblowers  
✅ **Accessibility** - Public can submit without barriers
✅ **Transparency** - Process clearly explained to submitters

### World Bank ESS Requirements
- Environmental and Social Standard 10 (ESS10)
- Grievance Redress Mechanism (GRM) requirements
- Confidentiality and protection from retaliation

---

## Summary

| Aspect | Before | After |
|--------|--------|-------|
| TP sees submitter name | ✅ Yes | ❌ No |
| TP sees submitter email | ✅ Yes | ❌ No |
| TP sees submitter phone | ✅ Yes | ❌ No |
| TP sees feedback text | ✅ Yes | ✅ Yes |
| TP can respond | ✅ Yes | ✅ Yes |
| Admin sees personal data | ✅ Yes | ✅ Yes |
| Public form privacy notice | ❌ No | ✅ Yes |
| Email privacy protection | ❌ No | ✅ Yes |
| Export privacy protection | ❌ No | ✅ Yes |

---

**Last Updated:** August 14, 2026
**Version:** 1.0
**Compliance:** ESS10, GRM Best Practices
