Abu Huraira reported Allah's Messenger ﷺ as saying that a servant transgressed the limit in committing sins. The rest of the hadith is the same but there is no mention of the story of the cat in it and in the hadith transmitted on the authority of Ziibaidl (the words are): " Allah, the Exalted and Glorious, said to everything which had taken a part of lies ashes to return what it had taken".
The lesson here is that even though it may seem like no one else knows when you do something wrong, Allah does know and He will hold you accountable for your actions so it's important to always strive towards doing good deeds instead of bad ones.