BUG: Index.join with different names doesn't return None name
State: closed

- [ ] closes #57065 (Replace xxxx with the GitHub issue number)
- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions.
- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.


Labels:
name: Reshaping
description: Concat, Merge/Join, Stack/Unstack, Explode
name: Index
description: Related to the Index class or subclasses

Comments:
I think this introduces an inconsistency between the non-unique and monotonic join paths.

xref https://github.com/pandas-dev/pandas/issues/55815 where @rhshadrach and I tried to determine the intended behavior. 

When left/right names differ, the choices seem to be:
- set name to none
- set name to caller (left)
- set name to caller (left) in all cases except `how="right"`

As of 2.2.0 I think there are cases of 1 and 3 occuring in various places. #56948 attempted to implement case 3 consistently but maybe it should be case 1 as you're doing in this PR.
Thanks for the reference @lukemanley 

For `set name to caller (left) in all cases except how="right"`, is there any case where "caller" is "ambiguous" with a function based join like `pd.concat` or `pd.merge`? Should that apply to arithmetic operations too idx1 + idx2 ~ `idx1.__add__(idx2)`?

I slightly prefer the return None approach as it's already being done in arithmetic cases and appears simpler, but not sure if there's a use case where joins specifically should keep names.
> I slightly prefer the return None approach as it's already being done in arithmetic cases and appears simpler, but not sure if there's a use case where joins specifically should keep names.

Are we meaning to have different rules for Index vs Series?

```
idx1 = Index([1, 1, 2, 3], name="a")
idx2 = Index([2, 5, 3, 4], name="b")

ser1 = pd.Series(1, index=idx1)
ser2 = pd.Series(2, index=idx2)

print(idx1+idx2)
# Index([3, 6, 5, 7], dtype='int64')

print(ser1+ser2)
# a
# 1    NaN
# 1    NaN
# 2    3.0
# 3    3.0
# 4    NaN
# 5    NaN
# dtype: float64
```

I can't say I've ever directly used `Index.join`, only `DataFrame.join`. Likewise with arithmetic. But if there isn't a good reason why these two behaviors should diverge (not sure), I would think users expect them to match.
> I slightly prefer the return None approach as it's already being done in arithmetic cases and appears simpler, but not sure if there's a use case where joins specifically should keep names.

Keeping consistency with implicit alignment (e.g. arithmetic cases) seems reasonable to me. 
OK with merging here?
> OK with merging here?

It looks like this only impacts the `_join_non_unique` path. Doesn't this create an inconsistency with `_join_monotonic`? For example, what would this return:

```
import pandas as pd

a = pd.Index([1, 2, 3], name="a")
b = pd.Index([2, 3, 4], name="b")

a.join(b, how="inner")
```
> OK with merging here?

I think it'd be good to decide if we are okay with the discrepancy between Index and Series behavior (https://github.com/pandas-dev/pandas/pull/57074#issuecomment-1912579392) that this is further widening. It seems to me changing Series behavior would be quite disruptive, while I personally never do arithmetic with index objects.
I guess this needs more discussion first so I'll close for now
@mroeschke - any thoughts on the discrepancy between the resulting name of `idx1 + idx2` and `ser1 + ser2` in https://github.com/pandas-dev/pandas/pull/57074#issuecomment-1912579392?
I also think there shouldn't be a result-name discrepancy between `idx1 + idx2` and `ser1 + ser2`, but namely `get_op_result_name` should also be used in both these cases