BUG: fix treatment of NaNs when .apply() function is used on categorical columns.
- [x] closes #59938
- [x] [Tests added and passed] (modified existing test function to accommodate change for `NaN` in cat columns)
- [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [x] Added an entry in the latest `doc/source/whatsnew/v3.0.0.rst` file if fixing a bug or adding a new feature.

RFR and looking forward to any suggested edits @mroeschke  Thanks @saldanhad 