Apps Script function for Google Sheets: Long formula(?) causing error: `SyntaxError: missing ) after argument list line: 14 file: new line.gs`

The Apps Script function in question:

function insertNewRow() {
  var ss = SpreadsheetApp.openById("redactedforprivacy");
  var sheet = ss.getSheetByName("Main");
  sheet.insertRowBefore(2);
  
  var date = new Date();
  var month = date.getMonth() + 1;
  var day = date.getDate();
  var year = date.getFullYear().toString().substr(-2);
  var formattedDate = month + "/" + day + "/" + year;
  
  sheet.getRange("A2").setValue(formattedDate);
  sheet.getRange("C2").setFormula("=ADD(C3,B2)");
  sheet.getRange("G2").setFormula("=IF(E2+F2>59,INT((E2+F2)/60)&IF(INT((E2+F2)/60)=1," hour"," hours")&" and "&MOD(E2+F2,60)&IF(MOD(E2+F2,60)=1," minute"," minutes"),MOD(E2+F2,60)&IF(MOD(E2+F2,60)=1," minute"," minutes");

}

The function makes a new row and adds some useful values and formulas in that row at various cells.

Like I said in the title, the error is as follows:

SyntaxError: missing ) after argument list line: 14 file: new line.gs

We’re focusing on line 14, where it sets the formula for the cell G2. The formula is probably pretty big and messy by someone else’s standards, but it works as expected on the spreadsheet. The error only occurs when line 14 is present, but I’m too stubborn to give up on the formula.

What I’ve tried:

(Disclaimer: I am not a programmer in any way, shape, or form.)

  1. I tried changing the formula around a few times, shortening it, changing it, trying to make it more efficient, but I couldn’t make any modifications that still worked on the spreadsheet; probably my own skill issue though.

  2. I looked through line 14 a numerous amount of times to try to find where it might be missing a faithful ), but I still can’t find it.