Expression for $\hat{\beta}$ in simple linear regression For simple linear regression, I have in my notes that
$\hat{\beta} =  \frac{\sum(x_i-\bar{x})(y_i-\bar{y})}{\sum(x_i-\bar{x})^2}=\frac{\sum(x_i-\bar{x})y_i}{\sum(x_i-\bar{x})^2}$
(was intended as a step in the proof that the covariance of the mean response and beta hat is 0) 
It seems however that this is not true unless $\bar{y}=0$. Does this have something to do with the fact that we will take the covariance?
Or, have I just mis-copied, and it should be
$\hat{\beta} =  \frac{\sum(x_i-\bar{x})(y_i-\bar{y})}{\sum(x_i-\bar{x})^2}=\sum\frac{(x_i-\bar{x})y_i}{\sum(x_i-\bar{x})^2}$,
as written here: Covariance term in simple linear regression?
From comments by @jbowman, @whuber
$\sum(x_i-\bar{x})\bar{y}=\sum x_i\bar{y}-\sum\bar{x}\bar{y}\implies\sum x_i\bar{y}=\sum\bar{x}\bar{y} \implies \bar{y}\sum x_i=\bar{x}\bar{y}\sum1 \implies \bar{y}\sum x_i=\bar{x}\bar{y}N\implies \bar{y}\bar{x}=\bar{x}\bar{y}$
 A: Algebraically, it is:
$$\hat{\beta} =  \frac{\sum(x_i-\bar{x})(y_i-\bar{y})}{\sum(x_i-\bar{x})^2}=\frac{\sum(x_i-\bar{x})y_i-\sum(x_i-\bar{x})\bar{y}}{\sum(x_i-\bar{x})^2}=\\
\frac{\sum(x_i-\bar{x})y_i-\bar{y}\sum(x_i-\bar{x})}{\sum(x_i-\bar{x})^2}=
\frac{\sum(x_i-\bar{x})y_i-\bar{y}\cdot 0}{\sum(x_i-\bar{x})^2}=\\
\frac{\sum(x_i-\bar{x})y_i}{\sum(x_i-\bar{x})^2}=\sum\frac{(x_i-\bar{x})y_i}{\sum(x_j-\bar{x})^2}.$$
Note:
$$\frac{\sum a_i}{\sum b_i}=\frac{\sum a_i}{\sum b_j}=\frac{a_1+a_2+\cdots+a_n}{\sum b_j}=\frac{a_1}{\sum b_j}+\frac{a_2}{\sum b_j}+\cdots+\frac{a_n}{\sum b_j}=\sum \frac{a_i}{\sum b_j}.$$
A: So first, we want to regress on $y$ and assume, so that
$\hat{y} =  \beta (x-\bar{x})$ (in vectorial notation)
with the loss function
$L = \sum_{i} (y_{i}-\hat{y}_{i})^{2} = \sum_{i} (y_{i}-\beta (x_{i}-\bar{x}))^{2}$
As it is already said, you can either regress on $y$ or on $y-\bar{y}$. The difference just lies in an additional constant so this will only change $\beta_{0}$ (the y-axis section).
Now we want to find the optimal beta, therefore
$\frac{\partial}{\partial \beta} L = \sum_{i} 2(y_{i}-\hat{\beta} (x_{i}-\bar{x}))\cdot (x_{i}-\bar{x}) = 0$
We can drop the factor of $2$ and rearrange the equation to
$\sum_{i} y (x_{i}-\bar{x})=\sum_{i} \hat{\beta} (x_{i}-\bar{x})^{2} $
$\Rightarrow \hat{\beta} = \frac{\sum_{i}y_{i}(x_{i}-\bar{x})}{\sum_{i}(x_{i}-\bar{x})^{2}}$ 
This last term on the right handside can be rewritten in the following ways
$   \frac{\sum_{i}y_{i}( x_{i}-\bar{x})}{\sum_{i}(x_{i}-\bar{x})^{2}} = \sum_{i}\frac{y_{i}(x_{i}-\bar{x})}{\sum_{i}(x_{i}-\bar{x})^{2}} $
Just be aware that the denominator is summed first.
