This code is duplicated with DocumentCommandHandlers.  Even if we can't fully unify these two codepaths for opening multiple items, could we move this filtering logic into a shared utility function?