In cases where you have set the configuration to Hide all out of stock items in search results on your Shopify store, you may encounter with a scenario where those products where 'Track quantity' is disabled are not retrieved either.
Even though you disable 'Track quantity' on your products, Shopify keeps record of the last stock this product had on the
inventory_quantity attribute. Additionally, Shopify continues to subtract
inventory_quantity whenever some one purchase your products. Once the
inventory_quantity is set to 0 (or a negative number) it will be filtered out by the filter that is applied on our end to hide all out of stock items:
inventory_quantity > 0.
Because of this reason, resolving the issue to both hide your out of stock products and retrieve untracked products with accuracy is not something that we can resolve on our end.
Even though it is not ideal, there is a workaround that should help to display accurate results for this scenario. In this case, you would need to re-enable 'Track quantity' on your products, set a e.g. 99999 stock to those products, and then untack them again.