The cooperator removal flow deletes the wrong Firestore document from the answers collection.
In AnswerController.js, the code uses:
const answerDocumentId =
userToUpdate.myAnswers[`${payload.testDocId}`].testDocId
await super.delete(COLLECTION, answerDocumentId)
testDocId is the study ID, not the answer document ID. The UserAnswer model stores both testDocId and answersDocId, so the delete operation should use answersDocId.
Steps to Reproduce
- Create a study with an answersDocId.
- Add a cooperator so user.myAnswers[testDocId] contains both fields.
- Remove the cooperator.
- Check Firestore the real answer document still exists.
Expected Behavior
Deleting a cooperator should remove the correct document using answersDocId.