'Excel Custom Function #VALUE error when returning a salt hash

I have a custom excel function that calculates a salt hash and attempts to return the hash and the salt as an array. When I run the function, the values appear to be generated correctly but I get a #VALUE error when trying to display them and I'm not sure why. It appears that the issue is coming from the salt portion of the hash. Excel doesn't seem to like a value starting with "$" so if I add a space before the salt value then it works correctly. Why am I receiving a #VALUE error and how can I resolve it?

Excel AddIn Code

/**
 * Returns hash for input text.
 * @customfunction SALT_HASH
 * @param {string} text
 * @param {string} [salt]
 * @returns string[][]
 */
export async function saltHash(text: string, salt?: string): Promise<string[][]> {
  try {
    const saltHash = await api.saltHash(text, salt);
    const response = [[saltHash.hash, saltHash.salt]];
    Logger.info(response);
    return response;
  } catch (error) {
    Logger.error(new SaltHashErrorLog("Salt hash function call failed", text, salt, error).log());
    return [[`Salt hash function call failed: ${buildErrorMessage(error)}`]];
  }
}

Example API Response

{
    "hash": "1IDvJZuvNSLS3EQl7kD9jLm2qN7Sp5K",
    "salt": "$2b$10$BAsip4RJH8MMz0G7Dw5EvO"
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source