Found the cause for the error.
The UsersIDs is a method or extension on the OA role that returns list of user Ids.
The work around I found was to put the "select" into the LINQ and materialize it before the SelectMany.
So it looks something like
var tmp =
.Context.my_roles.Where(r => r.users.Select(u => u.UserId).Contains(userID)).ToList();
>(r => r.VisibleBookIDs()).Distinct<