Hi @Michael_Henry1 - yes, the records returned from a script query are “flat” and don’t take account of any groups you’ve made in the UI. But the results will take acount of the filters you have applied (if any).
In my experience, not only is the query result “flat”, it is not in the order displayed in the user interface. The results are sorted according to any specified sort, but not sorted according to grouping. Records from different groups may be interleaved with each other.
I just ran a test, and the returned records from querying a specific view with grouped records did maintain the group order, including the record order inside each group. Granted it was a small sampling, but I’d like to think that this behavior would extend to larger datasets as well.