The following is result 5.44 from Linear Algebra Done Right, fourth edition by Sheldon Axler:
Theorem. Suppose $V$ is finite-dimensional and $T \in \mathcal{L}(V)$. Then $T$ has an upper-triangular matrix with respect to some basis of $V$ if and only if the minimal polynomial of $T$ equals $(z-\lambda_1) \cdots (z-\lambda_m)$ for some $\lambda_1, \ldots, \lambda_m \in \mathbf{F}$.
Proof of forward direction. First suppose $T$ has an upper-triangular matrix with respect to some basis of $V$. Let $\alpha_1, \ldots, \alpha_n$ denote the diagonal entries of that matrix. Define a polynomial $q \in \mathcal{P}(\mathbf{F})$ by
$$ q(z) = (z - \alpha_1) \cdots (z - \alpha_n) $$
Then $q(T)=0$, by 5.40. Hence $q$ is a polynomial multiple of the minimal polynomial of $T$, by 5.29. Thus the minimal polynomial of $T$ equals $(z - \lambda_1) \cdots (z - \lambda_m)$ for some $\lambda_1, \ldots, \lambda_m \in \mathbf{F}$ with $\{\lambda_1, \ldots, \lambda_m\} \subseteq \{\alpha_1, \ldots, \alpha_n\}$.
Something seems off to me. We're letting $\alpha_1, \ldots, \alpha_n$ denote the diagonal entries of the upper-triangular matrix of $T$. By result 5.41 in the book, this means that $\alpha_1, \ldots, \alpha_n$ are the eigenvalues of $T$. By result 5.27(a), these must be the zeros of the minimal polynomial. But then in the proof, we say that $\{\lambda_1, \ldots, \lambda_m\} \subseteq \{\alpha_1, \ldots, \alpha_n\}$, which suggests to me there may be an $\alpha \in \{\alpha_1, \ldots, \alpha_n\}$ that is not in $\{\lambda_1, \ldots, \lambda_m\}$. If that's the case, then how can $(z - \lambda_1) \cdots (z - \lambda_m)$ possibly be the minimal polynomial if it is missing some $\alpha$ as a zero?