I would start by getting the column values that specify Base or Optimum. If Col "C" then:
//var types = SpreadsheetApp.getActiveSheet().getRange("C2:C").getValues() //assuming C1 is a heading. start at the first data row
Then, I'm guessing you have a column that shows the date the last time each car was washed? That would be better than keeping data in property service for 60+ days.
//var dates = SpreadsheetApp.getActiveSheet().getRange("D2:D").getValues() //assuming D1 is a heading. start at the first data row
Then, let's assume the checkboxes are in Col E.
-------------------
So first, add this function at the top of your code, outside of any function. It takes in a 2D array, and returns a 1D array. They are just easier to work with.
const flat = (arr) => arr.reduce((a, b) => (Array.isArray(b) ? [...a, ...flat(b)] : [...a, b]), []);
Then define the sheet and hold it in a variable:
var sheet = SpreadsheetApp.getActiveSheet();
//flatten both arrays
var types = sheet.getRange("C2:C").getValues() //assuming C1 is a heading. start at the first data row
types = flat(types)
var dates = sheet.getRange("D2:D").getValues()
dates = flat(dates)
Define today:
var d= new Date();
Now iterate through the dates (also keeping track of the array index)
dates.forEach( (date, index) => {
//do your date comparison however you want
if ( today - new Date(date) >= 30 && types[index] === 'Base' ) {
sheet.getRange("E" + index +2).setValue(false)
} else if ( today - new Date(date) >= 60 && types[index] === 'Optimum' ) {
sheet.getRange("E" + index +2).setValue(false)
}
})
Essentially, I'm doing the same as you are with your code, just more explicitly.
Putting it all together: (untested, may not work as is)
const flat = (arr) => arr.reduce((a, b) => (Array.isArray(b) ? [...a, ...flat(b)] : [...a, b]), []);
function unCheck(){
var sheet = SpreadsheetApp.getActiveSheet();
var d= new Date();
var types = flat(sheet.getRange("C2:C").getValues())
var dates = flat(sheet.getRange("D2:D").getValues());
dates.forEach( (date, index) => {
if ( (d.getTime() - new Date(date).getTime()) / (1000 * 3600 * 24) >= 30 && types[index] === 'Base' ) {
sheet.getRange("E" + index +2).setValue(false); //adjust what you add to index based on how many rows you skip + 1 since rows start at 1 and index starts at 0
} else
if ( (d.getTime() - new Date(date).getTime()) / (1000 * 3600 * 24) >= 60 && types[index] === 'Optimum' ) {
sheet.getRange("E" + index +2).setValue(false); //adjust what you add to index based on how many rows you skip + 1 since rows start at 1 and index starts at 0
}
})
}