[guided]The remaining condition for being a modular form is holomorphy at the cusp. We check it by using representatives adapted to Fourier expansions, and first verify why those representatives are valid. Let
\begin{align*}
\alpha=
\begin{pmatrix}
A & B\\
C & D
\end{pmatrix}
\in\Delta_n.
\end{align*}
Set $a:=\gcd(A,C)>0$. Choose $r,s\in\mathbb{Z}$ such that $rA+sC=a$, and define
\begin{align*}
\gamma_0:=
\begin{pmatrix}
r & s\\
-C/a & A/a
\end{pmatrix}.
\end{align*}
Then $\gamma_0\in SL_2(\mathbb{Z})$ because $\det\gamma_0=(rA+sC)/a=1$, and left multiplication gives
\begin{align*}
\gamma_0\alpha=
\begin{pmatrix}
a & b_0\\
0 & d
\end{pmatrix}
\end{align*}
with $d=n/a>0$. Multiplying on the left by $\begin{pmatrix}1&t\\0&1\end{pmatrix}\in\Gamma$ changes $b_0$ to $b_0+td$, so we may choose the unique residue $b$ satisfying $0\le b<d$. Uniqueness follows because if $\gamma\begin{pmatrix}a&b\\0&d\end{pmatrix}=\begin{pmatrix}a'&b'\\0&d'\end{pmatrix}$ with $\gamma=\begin{pmatrix}p&q\\r&s\end{pmatrix}\in\Gamma$, then the bottom-left entry gives $ra=0$, hence $r=0$; from $ps=1$ and $d,d'>0$ we get $p=s=1$, so $a'=a$, $d'=d$, and $b'=b+qd$. Since both $b$ and $b'$ lie in $\{0,\dots,d-1\}$, $b=b'$. Therefore a representative set for $\Gamma\backslash\Delta_n$ is
\begin{align*}
\alpha_{a,b,d}:=
\begin{pmatrix}
a & b\\
0 & d
\end{pmatrix},
\qquad
ad=n,\quad d>0,\quad 0\le b<d.
\end{align*}
For such a matrix, the slash action becomes
\begin{align*}
(f|_k\alpha_{a,b,d})(z)
=
n^{k-1}d^{-k}f\left(\frac{az+b}{d}\right),
\end{align*}
because the lower-left entry is $0$ and the lower-right entry is $d$. Hence
\begin{align*}
(T_n f)(z)
=
\sum_{\substack{ad=n\\ d>0}}
\sum_{b=0}^{d-1}
n^{k-1}d^{-k} f\left(\frac{az+b}{d}\right).
\end{align*}
Since $f$ is holomorphic at the cusp, it has a Fourier expansion with no negative powers:
\begin{align*}
f(z)=\sum_{m=0}^{\infty} c_m q^m,
\qquad q=e^{2\pi i z},
\end{align*}
for all $z\in\mathbb{H}$ with $\operatorname{Im}z$ sufficiently large. For each fixed divisor pair $(a,d)$ with $ad=n$ and $d>0$, the imaginary part of $w=(az+b)/d$ is $a\operatorname{Im}z/d$. Because there are only finitely many such pairs and finitely many values of $b$ for each $d$, we can require $\operatorname{Im}z$ to be large enough that every point $(az+b)/d$ lies in the half-plane where the Fourier expansion of $f$ converges locally uniformly. This local uniform convergence justifies substituting the expansion into each summand and then moving the finite sums over $a,d,b$ past the infinite Fourier series. Substituting $w=(az+b)/d$ gives
\begin{align*}
f\left(\frac{az+b}{d}\right)
=
\sum_{m=0}^{\infty}
c_m
\exp\left(2\pi i m\frac{az+b}{d}\right)
=
\sum_{m=0}^{\infty}
c_m q^{ma/d}\exp\left(\frac{2\pi i mb}{d}\right).
\end{align*}
Therefore
\begin{align*}
(T_n f)(z)
&=
\sum_{\substack{ad=n\\ d>0}}
n^{k-1}d^{-k}
\sum_{b=0}^{d-1}
\sum_{m=0}^{\infty}
c_m q^{ma/d}\exp\left(\frac{2\pi i mb}{d}\right)\\
&=
\sum_{\substack{ad=n\\ d>0}}
n^{k-1}d^{-k}
\sum_{m=0}^{\infty}
c_m q^{ma/d}
\sum_{b=0}^{d-1}\exp\left(\frac{2\pi i mb}{d}\right).
\end{align*}
The inner sum over $b$ is a finite geometric sum over the $d$th roots of unity. It equals $d$ exactly when $d$ divides $m$, and it equals $0$ otherwise:
\begin{align*}
\sum_{b=0}^{d-1}\exp\left(\frac{2\pi i mb}{d}\right)
=
\begin{cases}
d, & d\mid m,\\
0, & d\nmid m.
\end{cases}
\end{align*}
Thus only the terms $m=d\ell$, with $\ell\in\mathbb{Z}_{\ge 0}$, remain. Substituting $m=d\ell$ gives
\begin{align*}
(T_n f)(z)
&=
\sum_{\substack{ad=n\\ d>0}}
n^{k-1}d^{1-k}
\sum_{\ell=0}^{\infty}
c_{d\ell}q^{a\ell}.
\end{align*}
This is a Fourier series in nonnegative integral powers of $q$, because $a\ell\ge 0$. Equivalently, if $r\ge 0$, the coefficient of $q^r$ is obtained by requiring $r=a\ell$, so $a\mid r$ and $d=n/a$. The coefficient is then
\begin{align*}
\sum_{a\mid \gcd(n,r)} a^{k-1}c_{nr/a^2}.
\end{align*}
For $r=0$, the same formula means that every divisor $a$ of $n$ contributes to the constant term. The important conclusion is that no negative powers of $q$ appear, so $T_n f$ is holomorphic at the cusp.[/guided]