I don't know exactly what your schema looks like, so I'm taking a stab in the dark here...
It looks like you are trying to perform the "ALL" functionality in this code. You don't want to waste time selecting a check box that is already selected, so you only want to get those that are not selected. So the XPath might look something like:
selectNodes("/my:myFields/my:officesAffected/my:OfficeAffected[. != 'true']")
Once you have your collection of unselected check boxes, then you just loop through them as you are doing and set their value as selected:
items(i).text = "true"
Greg Collins [InfoPath MVP]