Expense Tracker Delete Transaction Not Working

I cannot get my code to delete transactions from the list. If anyone is able to help I would appreciate it. Here is my code

import { createSlice } from '@reduxjs/toolkit';

export const CATEGORIES = ['housing', 'food', 'transportation', 'utilities', 'clothing', 'healthcare', 'personal', 'education', 'entertainment'];
const initialState = Object.fromEntries(CATEGORIES.map(category => [category, []]))

const transactionsSlice = createSlice({
  name: 'transactions',
  initialState: initialState,
  reducers: {
    addTransaction: (state, action) => {
      const newTransaction = action.payload;
      const transactionCategory = action.payload.category;
        state[transactionCategory].push(newTransaction);
    },
    deleteTransaction: (state, action) = {
      const transactionToRemove = action.payload;
      const transactionCategory = action.payload.category;
      state[transactionCategory] = state[transactionCategory].filter(transaction => transaction.id !== transactionToRemove.id);
    }
  }
})

export const selectTransactions = (state) => state.transactions;
export const selectFlattenedTransactions = (state) => Object.values(state.transactions).reduce((a,b) => [...a, ...b], []);

export default transactionsSlice.reducer;
export const { addTransaction, deleteTransaction } = transactionsSlice.actions;

It’s because the filter() method returns a new array and the Immer library under the hood of reduxjs/toolkit does not like that. If you change it to a method that mutates the original array, then Immer will be happy and it should work the way you want it to. splice() should work.