diff --git a/google-apps-script/AdminSync.gs b/google-apps-script/AdminSync.gs index a940343..0c31be0 100644 --- a/google-apps-script/AdminSync.gs +++ b/google-apps-script/AdminSync.gs @@ -70,6 +70,10 @@ function adminUpdate_(sheet, payload) { } var normalized = adminValidateChanges_(changes); + var currentDecision = clean_(current[COL.FINAL_DECISION - 1]) || 'Pending'; + if (normalized.finalDecision !== currentDecision) { + normalized.notificationStatus = 'Not Sent'; + } sheet.getRange(rowNumber, COL.INTAKE_STATUS, 1, 9).setValues([[ normalized.intakeStatus, sheetText_(normalized.reviewer1), diff --git a/scripts/test_sheets_sync.mjs b/scripts/test_sheets_sync.mjs index c3aa6b9..bd46c26 100644 --- a/scripts/test_sheets_sync.mjs +++ b/scripts/test_sheets_sync.mjs @@ -666,9 +666,32 @@ assert.equal(acceptedRow[21], "Sent"); assert.equal(brevoRequests.length, 2, "acceptance notification must use the same Brevo path"); assert.equal(brevoRequests[1].body.subject, "[PBAST10] Abstract accepted — brevo-submission-1"); -acceptedRow[19] = "Reject"; -acceptedRow[20] = "None"; -acceptedRow[21] = "Not sent"; +for (const priorNotificationStatus of ["Sent", "Confirmed"]) { + acceptedRow[19] = "Accept"; + acceptedRow[20] = "Oral"; + acceptedRow[21] = priorNotificationStatus; + const rejectionUpdate = JSON.parse(context.adminUpdate_(tracker, { + submissionId: "brevo-submission-1", + expectedFingerprint: context.adminFingerprint_(acceptedRow), + changes: { + intakeStatus: "Checked", + reviewer1: "", + reviewer1Decision: "", + reviewer2: "", + reviewer2Decision: "", + finalDecision: "Reject", + finalPresentationType: "None", + notificationStatus: priorNotificationStatus, + notes: "", + }, + }).body); + assert.equal(rejectionUpdate.ok, true); + assert.equal( + rejectionUpdate.row.notificationStatus, + "Not Sent", + `changing the final decision must reset ${priorNotificationStatus}`, + ); +} const rejection = callAppsScript({ action: "admin-rejection-email", submissionId: "brevo-submission-1",