Do not crash when trying to merge an invisible group
We should check whether a list contains any items before trying to get the first item from the list.
BUG:411124 BACKPORT:krita/4.2