How can I update a part of an array and then write that specific updated information to a sheet in Apps Script?

First of all I have some experience with coding but it is mostly self taught and very rusty. I am trying to write a script that takes information about boxes and their contents from a spreadsheet with a check after date, and use that information to create calendar events for each box, and then write the event IDs back to the sheet in order to avoid creating duplicate events.

Piecing together various code and ideas from different posts I have managed to get the script to check if an event exists and if it doesn’t to create it. The issue I seem to be running into is I am trying to update the sheet with the newly created event IDs and I seem to only be able to grab the last event ID and write that single entry back. Here is what I have so far:

//    0 Box | 1 Location | 2 Date Closed | 3 Check Date | 4 Start Time | 5 Count | 6 EventID

function syncCal() {
  const calId = "correct calendar"; // Test calendar
  const cal = CalendarApp.getCalendarById(calId);
 
  const sh = SpreadsheetApp.openById("sheet link"); // Change to correct Spreadsheet
  const ss = sh.getSheetByName("Box Tracker"); // Change to correct sheet

  let data = ss.getRange(2,1,ss.getLastRow(),8).getValues();
  //let info = idRange.getValues();
  let box, loc, d1, d2, t, count, title;
  

  for (let i in data){
  box = data[i][0];
  loc = data[i][1];
  d1 = new Date(data[i][3]);
  t = new Date(data[i][4]);
  count = data[i][5];
  var id = [[data[i][6]]];
  title = "Check Box #" + box;
   
  d1.setHours(t.getHours(),t.getMinutes());
  d2 = new Date(d1.getTime() + 30 * 60000);

    // Check if event already exists, update it if it does
    // Excludes rows that have no value in A2:A
    
  if (box !== "") try {
    var event = cal.getEventSeriesById(data[i][6]);
    Logger.log("Verified " + event.getTitle() + ' ID: ' + event.getId());
    event.setTitle('got you'); // this is to "force error" 
    event.setTitle(title);
  } catch (e) {
    Logger.log("Creating event...")
    //cal.createEvent(title, new Date("March 3, 2010 08:00:00"), new Date("March 3, 2010 09:00:00"), {description:desc,location:loc});
    var newEvent = cal.createEvent(title, d1, d2, {description:count + " in box.",location:loc});
    data[i][6] = newEvent.getId(); // Update the data array with event ID
    
    var event = cal.getEventSeriesById(data[i][6]);
    Logger.log('Created new event ' + event.getTitle() + ' ID: ' + event.getId());
    
    event.setTitle(title);
    event.setDescription(count + " in box.");
    event.setLocation(loc);
    Logger.log(data[i][6]);
    }
  
    var eventID = id.concat([]);
    Logger.log('eventID Array');
    Logger.log(eventID);
  }


  var idRange = ss.getRange(2,7,eventID.length,1);

  // Record all event IDs to spreadsheet
  idRange.setValues(eventID);
  }

Here is an example spreadsheet that it is trying to use:
Snapshot of spreadsheet

I know I could just write all the values back to the sheet but I am trying to avoid doing that since that would overwrite the formulas that are present in the primary sheet.

Any and all help or advice would be greatly appreciated!