Hi @john john Pter
Thank you for posting your question in the Microsoft Q&A forum.
Based on my research, the query will not fail even if the first condition returns more than 5000 results if you have enabled pagination and set threshold to maximum (100000).
Go into Settings and turn on Pagination, then set a Threshold to something greater than the number of items you expect to have.
When you set Pagination on, it will return the Top Count in batches. So, if your Top Count is 5000, it will return the first 5000, then the next 5000, and so on until all items are returned or it reaches your Threshold.
Some related articles that might help:
Solved: Sharepoint Get Items - Not Returning All Records
Get Over 5000 Items From A SharePoint List In Power Automate
Note: Microsoft is providing this information as a convenience to you. These sites are not controlled by Microsoft, and Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please ensure that you fully understand the risks before using any suggestions from the above link.
I hope this information helps.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.