Note that your last three records have the same transaction date, so the date alone is not unique enough for this to get ordered properly. If you add another more unique thing in the mix then it should work. Let’s also include the ID:
pocket.transactions.order(:transaction_date, :id).where("transaction_date < ?", "2024-02-04").last
(Also note that “ASC” is the default for .order
since it is SQL’s default for ORDER BY.)