There is no one-size-fits-all answer to this question since every agent and publisher may have a different perspective on self-publishing. However, there are a few things to consider when it comes to traditional publishing and self-publishing.
First, it's important to understand that traditional publishers are primarily interested in manuscripts that have not yet been published. They want to be the first to bring a book to market and have it appear under their imprint. This is because book publishing is a business, and traditional publishers need to be able to invest in a book and recoup their costs in order to turn a profit.
That being said, there are instances where a self-published book may catch the attention of a traditional publisher. This is particularly true if the book has been successful in finding an audience and has generated positive reviews and word of mouth. In this case, the publisher may see the potential to take the book to the next level and offer wider distribution, marketing support, and a higher production value.
However, it's also important to recognize that self-publishing can be looked down upon by some people in the publishing industry. Some may view it as a sign that an author was unable to secure a traditional book deal, or as a reflection of the quality of the writing or editing. Additionally, if an author has self-published a book that has not been successful, it may be seen as a negative mark against them when trying to query agents or publishers.
Overall, the best approach is to be honest and upfront about any previous self-publishing experience with agents and publishers. If a book has been self-published and has been successful, that can be a positive factor in the querying process. If the book has not been successful or has been poorly received, it may be better to focus on new projects and avoid mentioning the self-published book in queries or submissions.
Ultimately, the most important factor for traditional agents and publishers is the quality of the writing and the potential commercial viability of the project. If a self-published book meets those criteria, it may be seen as a positive rather than a negative. If it doesn't, the self-publishing experience is unlikely to have much impact on the outcome.