According to the documentation (https://developers.google.com/drive/api/v3/reference/permissions) the allowFileDiscovery permission is what determines if an item is indexed for search. Currently the checks in permissionList are only using the 'type' and 'id' fields to determine permissions. If I'm not mistaken, this would cause unreliable results.