BUG: to_datetime(..., infer_datetime_format=True) fails with np.str_input
- [x] closes #48969 (Replace xxxx with the Github issue number)
- [x] [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
- [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [x] 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.

I haven't added a whatsnew note as this worked fine in the last released versions, it just fixes a regression introduced between releases so makes no difference to users

Same kind of thing as https://github.com/pandas-dev/pandas/pull/45280
Thanks @MarcoGorelli (Finally have the walrus operator in the code base!) > Finally have the walrus operator in the code base!

Wave of the future!