How to get Invoice comments list programmatically in Magento 2?

Invoice comments will be added by the Store admin representative from the backend for the invoice query.

Comments can be notified by customer email and also display in the frontend invoice section if the checkbox is checked by the admin when creating any new comments from the backend.

The class responsible for the fetch list of comments from the invoice, Magento\Sales\Api\InvoiceManagementInterface

Call method with a required parameter, Be careful to assign Invoice Id, not the order id. Verify Invoice has Comments available or not by the getTotalCount().

Output: Magento\Sales\Api\Data\InvoiceCommentSearchResultInterface

If the Invoice contains the Comments, the response will be an array of comments otherwise value will be null.

You might be interested in the article, Capture Invoice programmatically.