I am working on an application which tracks your debts. I made an array which has all the information stored about each person and their owes. When I try to add a new debt (owe) my Alert that I use for debugging in React Native shows exactly the array I wanted to achieve, but I still get an error. Do you have any ideas how I can fix it? I'd appreciate any kind of help.
My Array:
const [owes, setOwes] = useState([
    {
      id: 1,
      name: "Frank",
      pic: require("../assets/blank_pic.png"),
      owes: [
        {
          id: 2,
          desc: "Cup of coffee",
          amount: -5.75,
          date: "15/07/18",
          time: "15:00",
        },
      ],
    },
    {
      id: 2,
      name: "Elizabeth",
      pic: require("../assets/blank_pic.png"),
      owes: [
        {
          id: 3,
          desc: "TV",
          amount: 50,
          date: "17/08/17",
          time: "12:05",
        },
      ],
    },
   ])
It's not the complete array... but it shows how it's structured.
My code:
const addOwe = (owe) => {
    owe.id = uuid.v4();
    owe.date = "15/07/18";
    owe.time = "16:00";
    setOwes((prevOwes) => {
      prevOwes.map((person) => {
        if (person.name === owe.name) {
          person.owes = [...person.owes, owe];
          Alert.alert("Array", JSON.stringify(prevOwes));
          return prevOwes;
        }
      });
    });
    props.setModalOpen(false);
  };
Error:
TypeError: undefined is not an object (evaluating 'owes.map')
 
    