REPORTS-197: Moved code for grouping reports to the controller