Updated the Task flattenArray function to account for the two different types of TaskGroupType arrays