i have one object that one of the properties is an array of objects, the idea is to move objects from that array to no new one if one condition is true.
You are removing elements as you loop through your array - this is never a good idea. A better way to solve this issue is to add them to this.comments first and when the foreach is finalized, start looping over this.comments and remove those that are in this array out of the messages.