If the tensor product of algebras $A \otimes B$ is unital, both $A$ and $B$ must be unital It is clear that if $A$ and $B$ are unital algebras (over a field), then the tensor product $A \otimes B$ is also unital, with the unit being $1_A \otimes 1_B$. I came across an exercise that questions about the converse statement. That is, if $A \otimes B$ is a unital non-zero algebra then $A$ and $B$ must also be unital.
I started by denoting $e$ the unit of $A \otimes B$. We can write $e = \sum_{i=1}^{n} a_i \otimes b_i$, with $n$ being minimal. This minimality implies that $a_1, \cdots, a_n$ and $b_1, \cdots, b_n$ are linearly independent. If we can prove that $n = 1$, then $e = a \otimes b$ is a pure tensor. These elements $a \in A$ and $b \in B$ are the ideal candidates for units in $A$ and $B$, respectively. However, I have not been able to arrive to a contradiction if $n > 1$ using only the basic tools and computations of tensors. Since no properties from $A$ or $B$ are assumed, I do not know what other tools can be used in this generality.
Note: Said exercise can be found in Introduction to Noncommutative Algebra by M. Bresar, chapter 4, page 104.

I was able to find a positive answer thanks to my lecturer who, as far as I know, is not present on M.SE. I will write a proof based on the idea he gave me, which is his credit.
Let $A$, $B$ be algebras over a field $F$ and suppose $A \otimes B$ is nonzero and unital. Since $A \otimes B$ is nonzero, then both $A$ and $B$ are nonzero. Take $0 \neq x \in A$ and $y \in B$ arbitrary elements. Write $e = \sum_{i=1}^{n} a_i \otimes b_i$ (as I did on the question). Since $e$ is the unit in $A \otimes B$, we have
\begin{align} x \otimes y = (x\otimes y)e = \sum_{i=1}^{n} xa_i \otimes yb_i  \tag{1}. \end{align}
Furthermore, since $x \neq 0$, we can expand $x$ to a basis of $A$ and hence, write $xa_i = \lambda_ix + v_i$, where $\lambda_i \in F$ and $v_i$ is linearly independent with $x$. Plugging this to $(1)$, we get
\begin{align} x \otimes y = \sum_{i=1}^{n} (\lambda_i x +v_i)\otimes yb_i  =  x \otimes\sum_{i=1}^{n} \lambda_i y b_i + \sum_{i=1}^{n} v_i \otimes yb_i \tag{2}\end{align}
or equivalently, after arranging terms
\begin{align} x \otimes (y - \sum_{i=1}^{n}\lambda_i y b_i)= \sum_{i=1}^{n} v_i \otimes yb_i \tag{3}.\end{align}
Since $x$ is linearly independent with each $v_i$, we conclude that
\begin{align} y = \sum_{i=1}^{n}\lambda_i y b_i = y (\sum_{i=1}^{n} \lambda_ib_i) \tag{4}\end{align}
(via a result on linear independence of tensor products, for instance, Lemma 4.8 in Bresar).
Analogously, using $x \otimes y = e(x \otimes y)$, we can conclude that $y = (\sum_{i=1}^{n} \lambda_ib_i)y$ and since $y \in B$ is arbitrary, this means that $\sum_{i=1}^{n} \lambda_ib_i$ is the unit of $B$.
The same argument works for proving that $A$ has unit as well.
