Yes. If you have a $4,000 carryover from 2022 to 2023 it will offset any gain and then if there is still a loss, you will be allowed up to $3,000 loss on the 2023 return. If there is any carryover in 2023 it will be calculated and carried to 2024. Here are some links with more information.
**Say "Thanks" by clicking the thumb icon in a post
**Mark the post that answers your question by clicking on "Mark as Best Answer"