I think this should be broken out into a private method instead of the duplication. You can also use map to clean it up a bit further.

Something like:
```ruby
private
def grantee(account)
  valid_email?(account) ? { 'EmailAddress' => account } : { 'ID' => account }
end
```

Which would be called like:
```ruby
accounts_with_access = accounts.map do |account|
  { 'Grantee' => grantee(account), 'Permission' => 'READ' }
end