BUG: Incorrect index shape when using a user-defined function for aggregating a grouped series with object-typed index.
- [x] closes #40014
- [x] tests added / passed
- [x] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing.html#code-standards) for how to run them
- [x] whatsnew entry

> Thanks for the pr! Some quick comments, plus can you please add a whatsnew?

Done. Added whatsnew  targetting 1.2.4, but let me know if this is not the case. I am opening this PR for review again. I have added another test, not sure on which one to keep. Open to any suggestions. > 
> 
> This looks great! Can you just check on my example in the issue and report back? Do you understand why the "> 0" was causing it to fail? It's still not clear to me from the diff in this PR.

I addressed your question here: https://github.com/pandas-dev/pandas/issues/40014#issuecomment-819489220 lgtm. cc @jbrockmendel if any comments @rhshadrach over to you Thanks @DriesSchaumont, very nice!